Skip to content

MacFJA/phptransformer-twital

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Twital for PHPTransformers

Twital support for PHPTransformers.

Install

Via Composer

$ composer require macfja/phptransformer-twital

Usage

$engine = new TwitalTransformer();
echo $engine->render('Hello, {{ name }}!', array('name' => 'phptransformers');

Special case for string rendering (render)

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()
    )
);

Testing

$ phpunit

License

The MIT License (MIT). Please see License File for more information.

About

Twital support for PHPTransformers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages