PHPackages                             codelake/template-flow - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. codelake/template-flow

ActiveLibrary[Templating &amp; Views](/categories/templating)

codelake/template-flow
======================

A simple and extendable templating engine.

0.1.0(7y ago)23UnlicensePHP

Since Dec 5Pushed 7y agoCompare

[ Source](https://github.com/codelakegmbh/template-flow-php)[ Packagist](https://packagist.org/packages/codelake/template-flow)[ RSS](/packages/codelake-template-flow/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (1)Dependencies (2)Versions (3)Used By (0)

TemplateFlow
------------

[](#templateflow)

TemplateFlow is a simple and extendable templating engine with a focus on E-Mail and HTML templating. Therefore, TemplateFlow may not work as expected if you want to output plain text which contains HTML special characters like `set_template('Hello {{name}}!');
$engine->set_data(['name' => 'foo']);
$result = $engine->render(); // evaluates to 'Hello foo!'
```

### Pipes

[](#pipes)

Replacing placeholders with values is already nice to have but not really powerful. Therefore, TemplateFlow provides pipes. Pipes allow you to specify how a given placeholder value should be mutated before it is displayed. TemplateFlow already comes with a lot of predefined pipes. A complete list of the predefined pipes can be found at [Predefined Pipes](#predefined-pipes)

```
use CodeLake\TemplateFlow\TemplatingEngine;
$engine = new TemplatingEngine();
$engine->set_template('Hello {{name|capitalize}}!');
$engine->set_data(['name' => 'foo']);
$result = $engine->render(); // evaluates to 'Hello Foo!'
```

There are also parameterized pipes - like `shorten` - which take a parameter. A parameter may be passed to a pipe in parenthesis.

```
use CodeLake\TemplateFlow\TemplatingEngine;

$engine = new TemplatingEngine();
$engine->set_template('Welcome {{name|shorten(4)}}.');
$engine->set_data(['name' => 'Johnny']);
$result = $engine->render();
// produces 'Welcome John.'
```

Some pipes also require more than one parameter. To distinct multiple parameters, the pipe operator (`|`) is used.

```
use CodeLake\TemplateFlow\TemplatingEngine;

$engine = new TemplatingEngine();
// use the capitalize pipe to make the first letter upper case
$engine->set_template('Please fill out our {{survey_link|link(Survey)}}!');
$engine->set_data(['survey_link' => 'www.example-survey.com']);
$result = $engine->render();
// produces anchor 'Survey'
```

### Adding Pipes

[](#adding-pipes)

Pipes are just functions in a `class`. Therefore, if you want to add your own pipes to TemplateFlow, you just have to create a new `class` with the desired pipes as static methods on it.

It is recommended to use snake\_case with lower case characters only, to guarantee easy to read pipes and prevent errors due to typos.

**NOTE** Since PHP is case insensitive in regard to function names, the use of camelCase and PascalCase are discouraged.

**NOTE** TemplateFlow will always try to execute discovered pipes (methods) in a static context. So, declaring a pipe as a normal method will lead to an exception.

```
use CodeLake\TemplateFlow\TemplatingEngine;

class MyPipes {
  /**
   * Returns the last character of a string.
   */
  static function last(string $value): string {
    return substr($value, -1);
  }
}

TemplatingEngine::pipes_register_class(MyPipes::class);
// all static methods of the class 'MyPipes' are now available as pipes
```

### Removing Pipes

[](#removing-pipes)

In case you want to unregister/remove pipes, you can easily unregister the corresponding class. This will prevent TemplateFlow from creating new `TemplatePipe`s with the class' methods. Existing `TemplatePipe`s will still work as they already loaded the methods.

```
use CodeLake\TemplateFlow\TemplatingEngine;

class MyPipes {
  /**
   * Returns the last character of a string.
   */
  static function last(string $value): string {
    return substr($value, -1);
  }
}

TemplatingEngine::pipes_register_class(MyPipes::class);
// all static methods of the class 'MyPipes' are now available as pipes
TemplatingEngine::pipes_unregister_class(MyPipes::class);
// the pipes are now unavailable for new pipelines
```

### Predefined Pipes

[](#predefined-pipes)

In order to use predefined pipes, you first have to add it to the engine.

```
use CodeLake\TemplateFlow\TemplatingEngine;
use CodeLake\TemplateFlow\TemplatePipes;

TemplatingEngine::pipes_register_class(TemplatePipes::class);
```

#### capitalize

[](#capitalize)

Mutates the first character of a string to upper case.

#### link

[](#link)

Creates a link (anchor tag) with the specified address.

##### usage - for web links

[](#usage---for-web-links)

```
use CodeLake\TemplateFlow\TemplatingEngine;

$engine = new TemplatingEngine();
$engine->set_template('Please fill out our {{survey_link|link(Survey)}}!');
$engine->set_data(['survey_link' => 'www.example-survey.com']);
$result = $engine->render();
// produces anchor 'Survey'
```

##### usage - for mailto links

[](#usage---for-mailto-links)

```
use CodeLake\TemplateFlow\TemplatingEngine;

$engine = new TemplatingEngine();
$engine->set_template('If you want, contact our {{support_link|link(Support|mail)}}!');
$engine->set_data(['support_link' => 'support@example.com']);
$result = $engine->render();
// produces anchor 'Support'
```

### lower

[](#lower)

Transforms all characters in a string to lower case.

### raw

[](#raw)

Returns a `RawOutput` instance, so the pipeline result will not be escaped.
**NOTE** This pipe has to be the last one in the chain. Otherwise the output will be escaped as usual.

### shorten

[](#shorten)

Cuts off the remaining characters of the pipeline string after the n-th character.

```
use CodeLake\TemplateFlow\TemplatingEngine;

$engine = new TemplatingEngine();
$engine->set_template('Welcome {{name|shorten(4)}}.');
$engine->set_data(['name' => 'Johnny']);
$result = $engine->render();
// produces 'Welcome John.'
```

### trim

[](#trim)

Removes all whitespace characters from the left and right side of a string.

### trim\_left

[](#trim_left)

Removes all whitespace characters from the left side of a string.

### trim\_right

[](#trim_right)

Removes all whitespace characters from the right side of a string.

### upper

[](#upper)

Transforms all characters in a string to upper case.

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2729d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/26442928?v=4)[Jörn Neumeyer](/maintainers/joernneumeyer)[@joernneumeyer](https://github.com/joernneumeyer)

![](https://avatars.githubusercontent.com/u/10589008?v=4)[Nirav](/maintainers/codelake)[@CodeLake](https://github.com/CodeLake)

---

Top Contributors

[![codelakegmbh](https://avatars.githubusercontent.com/u/44413799?v=4)](https://github.com/codelakegmbh "codelakegmbh (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/codelake-template-flow/health.svg)

```
[![Health](https://phpackages.com/badges/codelake-template-flow/health.svg)](https://phpackages.com/packages/codelake-template-flow)
```

###  Alternatives

[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3861.2M](/packages/limenius-react-bundle)[concrete5/core

Concrete – an open source content management system.

20163.8k49](/packages/concrete5-core)[area17/laravel-auto-head-tags

Laravel Auto Head Tags helps you build the list of head elements for your app

4616.0k](/packages/area17-laravel-auto-head-tags)[jelix/wikirenderer

WikiRenderer is a library to generate HTML or anything else from wiki content.

1712.2k1](/packages/jelix-wikirenderer)[webkinder/sproutset

A Composer package for handling responsive images in Roots Bedrock + Sage + Blade projects.

281.8k](/packages/webkinder-sproutset)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
