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 4d 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

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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

2683d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6e7fa9200c767d21cce211dcc4c3d014ea773a5fab63aafcf599007d8c318b42?d=identicon)[joernneumeyer](/maintainers/joernneumeyer)

![](https://www.gravatar.com/avatar/eaa9a3841d2c687cab34b3da160011ff34835ed5cd73a490b2a812b3b7363912?d=identicon)[codelake](/maintainers/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

[mustache/mustache

A Mustache implementation in PHP.

3.3k44.6M291](/packages/mustache-mustache)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[whitecube/nova-flexible-content

Flexible Content &amp; Repeater Fields for Laravel Nova.

8053.0M25](/packages/whitecube-nova-flexible-content)[mopa/bootstrap-bundle

Easy integration of twitters bootstrap into symfony2

7042.9M33](/packages/mopa-bootstrap-bundle)[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3871.2M](/packages/limenius-react-bundle)[nicmart/string-template

StringTemplate is a very simple string template engine for php. I've written it to have a thing like sprintf, but with named and nested substutions.

2101.7M30](/packages/nicmart-string-template)

PHPackages © 2026

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