Twital support for PHPTransformers.
Via Composer
$ composer require macfja/phptransformer-twital
$engine = new TwitalTransformer();
echo $engine->render('Hello, {{ name }}!', array('name' => 'phptransformers');
If you are using TwitalTransformer
to render template stored in a string variable, you need to indicate to Twital plugin the type of
string you are about to use (HTML5, XML, XHTML).
To do so you can pass a magic parameter to the render
function.
The parameter is named __twital-adapter
and its value is an instance of \Goetas\Twital\SourceAdapter
$engine = new TwitalTransformer();
echo $engine->render(
'<ul t:if="users">
<li t:for="user in users">
{{ user.name }}
</li>
</ul>',
array(
'users' => array(
array('name' => 'phptransformers'),
array('name' => 'twig'),
array('name' => 'twital')
),
'__twital-adapter' => new HTML5Adapter()
)
);
$ phpunit
The MIT License (MIT). Please see License File for more information.