mustache.erl
mustache.erl copied to clipboard
Lists within Lists doesn't work
Let's say we want a list within a list using the following:
Template = "{{#outer}} {{#inner}} x {{/inner}} {{/outer}}"
Ctx = dict:from_list([{outer, [ dict:from_list([{inner, []} ] )]}]).
when I run
mustache:render(Template, Ctx).
I get
** exception throw: {template,[66,97,100,32,99,111,110,116,101,120,116,32,102,
111,114,32,"inner",58,32,"[]"]}
bump It probably doesn't help much, but I'm get the same when I try and run nested loops like that
FYI : We ended up getting around the issue by pushing the first list through a multiple 'row' templates and then pushing all of that through a 'column' template - not particularly elegant.
{{#rows}}
{{{row}}}
{{/rows}}
Note the three braces on {{{row}}} are needed to ensure the string is not escaped by mustache and hence not leaving HTML code in the final rendering in the browser.