XaminProject / handlebars.php

Handlebars processor for php
331 stars 132 forks source link

Handlebars don't show error on undefined helper #150

Closed jcubic closed 8 years ago

jcubic commented 8 years ago

I've used this code:

$engine = new Handlebars();

echo $engine->render("{{#each foo}}{{this}}{{/each}}{{#escape}}{{foo}}{{/escape}}", array(
    'foo' => array(
        '1', '2', '3', '4'
    )
));

and handlebars don't show error that escape is not defined it just ignore it.

JustBlackBird commented 8 years ago

It's because of Mustache syntax fallback. In a Mustache template

{{#foo}}
    {{bar}}
{{/foo}}

the output will depend on what foo is: hash, empty value or lambda. The details could be found in Mustache docs.

In other words, I don't think it's a kind of bug.