Mustache inside of href

javascript, mustache, templates

Solution

Make sure your template source is straight text - don't try and grab parsed HTML source as your template. Browsers will urlencode/escape those characters in your link href, and result in those `%7Bs` and `%7Ds` you see in your code. Mustache won't recognize that.

I suppose unescaping the source you pass to mustache might work, though.

Mustache.render(unescape(source),view)

Problem

I have JSON like this: ``` { "something": "http://something.com" } ``` and HTML like this: ``` <a href="{{something}}">{{something}}</a> ``` When I apply Mustache, I get ``` <a href="%7B%7Bsomething%7D%7D">http://something.com</a> ``` But what I am trying to get is ``` <a href="http://something.com">http://something.com</a> ``` I already tried `{{{ something}}}`, `{{& something}}`, single quotes, double quotes... I even read documentation. Can you help me?

Original source

Related problems