Wednesday, 2 October 2013

Mustache with arrays, exception for the last item

Mustache with arrays, exception for the last item

var template = "multi: ";
//need => multi: option1; option2; option3 (no semicolon and space at the
end)
var json = {
"answerVOs": [
{ "answer" : "option 1"
},
{ "answer" : "option 2"
},
{ "answer" : "option 3"
}
]
};
document.getElementById("answers").innerHTML = Mustache.to_html(template,
json);
http://jsfiddle.net/casadev/GEbe8/1/
I need the last item in the array to be displayed without the semicolon
and space, any ideas.

No comments:

Post a Comment