Closed joshpangell closed 11 years ago
actually we don't have the mustache compatibility implemented yet so it won't iterate over planets if you do {{#planets}} ... {{/planets}}. also as far as I know list
is not within built-in helpers you should use each
instead or add list yourself. for built-in helpers take a look at http://handlebarsjs.com/#builtins
btw this works:
$h = new Handlebars_Engine;
echo $h->render(
'Planets:<br> {{#each planets}}<h6>{{planet}}</h6>{{/each}}',
array(
'planets' => array(
array('planet' => "Mercury"),
array('planet' => "Venus"),
array('planet' => "Earth"),
array('planet' => "Mars")
)
)
);
you can do the same with:
$h = new Handlebars_Engine;
echo $h->render(
'Planets:<br> {{#each planets}}<h6>{{.}}</h6>{{/each}}',
array(
'planets' => array("Mercury", "Venus", "Earth","Mars")
)
);
Except for {{^variable}} any other mustache like markup are available.
echo $h->render(
'Planets:<br> {{#planets}}<h6>{{.}}</h6>{{/planets}}', //like {{#each planets}}
array(
'planets' => array("Mercury", "Venus", "Earth","Mars")
)
);
echo $h->render(
'Planets:<br> {{#planets}}<h6>{{.}}</h6>{{/planets}}', //like {{#with planets}}
array(
'planets' => new Object()
)
);
echo $h->render(
'Planets:<br> {{#planets}}<h6>{{.}}</h6>{{/planets}}', //like {{#if planets}}
array(
'planets' => false
)
);
fixed in e3c29366941172842473434bc97bcddb3bbe8307
I first tried using the standard {{#}} iterator method:
Error:
When that did not work out, I tried to use the {{#list}} iterator:
Error: