Can mustache iterate a top-level array?

前端 未结 5 867
刺人心
刺人心 2020-12-04 08:21

My object looks like this:

[\'foo\',\'bar\',\'baz\']

And I want to use a mustache template to produce from it something like this:

5条回答
  •  春和景丽
    2020-12-04 08:48

    Building on @danjordan's answer, this will do what you want:

    Mustache.render('
      {{#.}}
    • {{.}}
    • {{/.}}
    ',['foo','bar','baz']);

    returning:

    • foo
    • bar
    • baz

提交回复
热议问题