Subexpressions allow you to invoke multiple helpers inside a tag. The result of inner helper will be arguments of outer helpers.
This is a handlebars.js extension, mustache do not support this.
Used option: FLAG_ADVARNAME
array(
"foo" => 0
)
Foo is zero
Foo is zero
Check the code to know used helper codes
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{#if (iszero foo)}}Foo is zero{{/if}}";
$php = LightnCandy::compile($template, array(
"flags" => LightnCandy::FLAG_ADVARNAME,
"helpers" => array(
"iszero" => function ($arg1) {
return ($arg1 === 0);
}
)
));
$render = LightnCandy::prepare($php);
$data = array(
"foo" => 0
);
echo $render($data);
{
"foo": 0
}
Foo is zero
Foo is zero
Check the code to know used helper codes
var Handlebars = require('handlebars');
var template = '{{#if (iszero foo)}}Foo is zero{{/if}}';
Handlebars.registerHelper({
'iszero': function (arg1) {
return (arg1 === 0);
}
});
var render = Handlebars.compile(template);
var data = {
"foo": 0
};
console.log(render(data));