A minimalistic templating engine for PHP
MIT License
Bot releases are hidden (Show)
Published by wol-soft about 1 year ago
Allow to assign callbacks to the template (prior versions were only capable to call methods on assigned objects) as well as the possibility to directly call PHP methods from the template.
Published by wol-soft about 1 year ago
The rendering now supports resolving constant values (integer numbers, strings in single quotes and booleans [true, false]):
<html>
<p>Products: {{ viewHelper.getTitle('mySite.title', true) }}</p>
<!-- TODO: fill with dynamic content -->
<span>Visitors: {{ 3000 }}</span>
</html>
Published by wol-soft almost 3 years ago
Allows to access public object properties from a template:
$person = new stdClass();
$person->name = 'Hans';
$render->renderTemplateString(
'{{ person.name }}',
[
'person' => $person,
]
);
Bugfixes: #5
Published by wol-soft almost 3 years ago
Allow attaching an error handler to handle undefined variable errors instead of triggering an UndefinedSymbolException:
$render->onResolveError(function (string $var): string {
return 'Undefined';
});
// will result in "Person name: Undefined"
$result = $render->renderTemplateString('Person name: {{ name }}');
Published by wol-soft almost 3 years ago
Provided data may be a nested array which can be resolved in the template:
$render->renderTemplateString(
'{{ render.productRender.renderProductName(product.details.name) }}',
[
'product' => [
'details' => [
'name' => 'MyProduct',
],
],
'render' => [
'productRender' => new ProductRender(),
]
]
);
Published by wol-soft almost 4 years ago
Loops now support the usage of key value pairs:
{% foreach products as bestSellerNumber, product %}
<b>Bestseller Nr. {{ bestSellerNumber }}:</b>{{ product.getTitle() }}<br/>
{% endforeach %}
Variable names may contain underscores:
{{ my_variable_will_be_resolved }}
Published by wol-soft about 5 years ago
Bugfix: if null is provided as a value to the template the corresponding key is recognized as undefined
Published by wol-soft over 6 years ago
Add not keyword to conditional statements
Published by wol-soft over 6 years ago
Fix successive loops
Published by wol-soft over 6 years ago
Add else to conditional statements
Published by wol-soft over 6 years ago
Published by wol-soft over 6 years ago