mojombo / mustache.erl

Mustache template engine for Erlang.
MIT License
239 stars 59 forks source link

Lists within Lists doesn't work #16

Open olishep opened 11 years ago

olishep commented 11 years ago

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,"[]"]}
timdouglas commented 11 years ago

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

olishep commented 10 years ago

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.