You can provide custom helper to handle logic
This is a handlebars.js extension, mustache do not support this.
array(
"foo" => 1,
"bar" => "1"
)
No
Check the code to know used helper codes
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{isequal foo bar}}";
$php = LightnCandy::compile($template, array(
"helpers" => array(
"isequal" => function ($arg1, $arg2) {
return ($arg1 === $arg2) ? 'Yes' : 'No';
}
)
));
$render = LightnCandy::prepare($php);
$data = array(
"foo" => 1,
"bar" => "1"
);
echo $render($data);
{
"foo": 1,
"bar": "1"
}
No
Check the code to know used helper codes
var Handlebars = require('handlebars');
var template = '{{isequal foo bar}}';
Handlebars.registerHelper({
'isequal': function (arg1, arg2) {
return (arg1 === arg2) ? 'Yes' : 'No';
}
});
var render = Handlebars.compile(template);
var data = {
"foo": 1,
"bar": "1"
};
console.log(render(data));