#1 2018-11-02 23:39:52

array81
Member
From: Italy
Registered: 2010-07-23
Posts: 411

Mustache sections and array of items

By mustache template I have fill a javascript array.
Something like this:

    var items= [
	  {{#item}}
          { "ID": {{ID}}, "Title": "{{Title}}", "Kind": {{Kind}}, "Code": "{{Code}}", "Date": "{{Date}}" },
	  {{/item}}
    ];

My problem is last item, this item in fact don't need of last comma.
Is there a way to avoid it?

Offline

#2 2018-11-03 08:08:20

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,543
Website

Re: Mustache sections and array of items

Trailing commas are allowed in JS and even in JSON starting from ES5 (all modern browser), so this is not a problem IMHO

Offline

Board footer

Powered by FluxBB