You can provide block custom helper to handle a block
This is a handlebars.js extension, mustache do not support this.
array(
"foo" => "World"
)
Hello, !
Hello, World!
Check the code to know used helper codes
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{#myloop foo}}Hello, {{.}}!{{/myloop}}";
$php = LightnCandy::compile($template, array(
"helpers" => array(
"myloop" => function ($arg1, $options) {
return $options['fn']($arg1);
}
)
));
$render = LightnCandy::prepare($php);
$data = array(
"foo" => "World"
);
echo $render($data);
{
"foo": "World"
}
Hello, !
Hello, World!
Check the code to know used helper codes
var Handlebars = require('handlebars');
var template = '{{#myloop foo}}Hello, {{.}}!{{/myloop}}';
Handlebars.registerHelper({
'myloop': function (arg1, options) {
return options['fn'](arg1);
}
});
var render = Handlebars.compile(template);
var data = {
"foo": "World"
};
console.log(render(data));