Is there a way to make a switch statement in Mustache.js
I have a variable which can be one of the four different values. Depends on its value I want to output slightly different template.
Is there a way to do this?
P.S I have seen this question, but nevertheless the question sounds the same, but in the answer the person was answering how to achieve if/else functionality, which I can find here.
Explanation about the code:
I have a list of templates
var templates = {
friends :
'here there is some html with {{vars}}'+
'and a button on which I have to write something like'+
'add to friends | already your friend | invitation was sent | your invitation was rejected'
}
}
So basically I am doing an ajax call and together with vars
it returns me type
, which can be one of the following things 0,1,2,3
. Depending on this, I have to write specific text