How can I get javascript mustache templating to work within square brackets

Thursday, July 10, 2014

I've been using mustache for a while now, and I've run into an issue which is not explained by the documentation. I want to have mustache place the result inside square brackets [], but instead of posting my result, it puts it in as literal


Say I have a mustache variable 'myvariable' and it has a value of 'XXX'



[label:{{myvariable}}]


this results in the following string after the template was applied:



[label:{{myvariable}}]


I would have suspected (and need) to have the following result:



[label:XXX]


I can't find anything in the documentation that explains why square brackets have an impact on the mustache templating syntax. If I place {{myvariable}} outside the square brackets, it works as expected and I get label:XXX. Can anyone provide me a workaround to achieve my goal?







http://ift.tt/1nhVMQI