mustache.erl icon indicating copy to clipboard operation
mustache.erl copied to clipboard

Lists within Lists doesn't work

Open olishep opened this issue 11 years ago • 2 comments

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,"[]"]}

olishep avatar Aug 02 '13 17:08 olishep

bump It probably doesn't help much, but I'm get the same when I try and run nested loops like that

timdouglas avatar Aug 05 '13 07:08 timdouglas

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.

olishep avatar Jun 03 '14 14:06 olishep