Reputation: 2512
I just noticed that when I use something like:
var template = '{{#link}} {{&link}} {{/link}}';
var json = {
link: "http://google.com"
};
var html = Mustache.render(template, json);
The output is
<a href="undefined">http://google.com</a>
But as far as I know there aren't any built-in functionality for links, right? Has anyone experienced the same problem?
Upvotes: 4
Views: 79
Reputation: 5117
You're running into a WTFJS!
You're calling String.prototype.link
:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/link
… and it's not doing what you think it should, because that function doesn't do what anyone thinks it should. There are a lot of fixes, but do yourself a favor and just don't name that property link
.
Upvotes: 2