An open API service indexing awesome lists of open source software.

https://github.com/frdl/php-templater

Templates {{my.var}} for ['my'=>['var'=>'Hello, World']]
https://github.com/frdl/php-templater

php-templater

Last synced: 9 days ago
JSON representation

Templates {{my.var}} for ['my'=>['var'=>'Hello, World']]

Awesome Lists containing this project

README

          

# php-templater
This package can process and render templates similar to AngularJS.

Templates {{my.var}} for ['my'=>['var'=>'Hello, World']]

# Examples

## frdl\Templater\SimpleDotNotationReplacer
Based on regular expression.

````php
$arr = [
'test' => [
'message' => 'Hello, World',
],

];

echo \frdl\Templater\SimpleDotNotationReplacer::replace(\frdl\Context::create($arr),
'Message: {{test.message}}');
//Message: Hello, World
````

## frdl\Templater\AdvancedReplacer
Based on https://github.com/wmde/php-vuejs-templating .

````php
$arr = [
'show' => false,
'test' => [
'message' => 'Hello, World',
],
'items' => [
[ 'property' => 'value1' ],
[ 'property' => 'value2' ],
],
];

echo \frdl\Templater\AdvancedReplacer::replace(\frdl\Context::create($arr),
'



Message: {{test.message}}


this should be hidden


this should be visible


{{item.property|ucfirst}}



');

/*
//Renders to:


Template Test Title


Message: Hello, World



this should be visible


Value1Value2



*/
````