XaminProject / handlebars.php

Handlebars processor for php
331 stars 134 forks source link

Add segment-literal notation for expressions #47

Closed JustBlackBird closed 10 years ago

JustBlackBird commented 10 years ago

I've added support for segment-literal notation for variables names as in Handlebars.js. In other words one can use value.[some key] syntax.

For example:

$engine = new \Handlebars\Handlebars();

echo $engine->render(
    '{{greetings.[hello world!]}}',
    array(
        'greetings' => array(
            "hello world!" => 'Hello from Handlebars'
        )
    )
);

The tests for such feature in handlebars.js are available here: http://jsfiddle.net/L7LWM/1/

everplays commented 10 years ago

thanks.

JustBlackBird commented 10 years ago

You are welcome

wwwsevolod commented 10 years ago

oh it is cool, waiting for subexpressions (if i've found free time, ill implement it myself)