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']]
- Host: GitHub
- URL: https://github.com/frdl/php-templater
- Owner: frdl
- License: mit
- Created: 2019-08-09T05:42:53.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-02-04T06:51:35.000Z (over 6 years ago)
- Last Synced: 2025-06-02T15:43:55.285Z (about 1 year ago)
- Topics: php-templater
- Language: PHP
- Size: 41 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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),
'
');
/*
//Renders to:
*/
````