问题
How to create active clickable links with Mustache? I prefer to use javascript version of Mustache for this.
In other words:
I want to autolink user generated text content with javascript/mustache (=linkify).
Template
{{#.}}
<div>{{.}}</div>
{{/.}}
Data
[
'User content, like regular text.',
'User content with text and links http://www.google.com or secure https://www.google.com'
]
Output I'm looking for
<div>User content, like regular text.</div>
<div>User content with text and links <a href="http://www.google.com">http://www.google.com</a> or secure <a href="https://www.google.com">https://www.google.com</a></div>
回答1:
Use {{{.}}} instead of {{.}} - this will not escape special characters.
来源:https://stackoverflow.com/questions/22019029/how-to-create-active-links-with-mustache