如何使用Moustache创建活动链接? [英] How to create active links with Mustache?
本文介绍了如何使用Moustache创建活动链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用Mustache创建有效的可点击链接?我更喜欢为此使用JavaScript版本的Mustache.
How to create active clickable links with Mustache? I prefer to use javascript version of Mustache for this.
换句话说:
我想用javascript/小胡子(= linkify)自动链接用户生成的文本内容.
I want to autolink user generated text content with javascript/mustache (=linkify).
模板
{{#.}}
<div>{{.}}</div>
{{/.}}
数据
[
'User content, like regular text.',
'User content with text and links http://www.google.com or secure https://www.google.com'
]
我正在寻找的输出
<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>
推荐答案
使用{{{.}}}代替{{.}}-这样就不会转义特殊字符.
Use {{{.}}} instead of {{.}} - this will not escape special characters.
这篇关于如何使用Moustache创建活动链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文