<!DOCTYPE html> <!-- To run the current sample code in your own environment, copy this to an html page. --> <html> <head> <script src="//code.jquery.com/jquery-1.11.3.js"></script> <base href="//www.jsviews.com/samples/"/> <link href="samples.css" rel="stylesheet"/> <script src="../download/jsrender.js"></script> </head> <body> <div id="result"></div> <script id="theTmpl" type="text/x-jsrender"> {{:description}}<br/> {{>description}} </script> <script> var data = { "description": "A <b>very nice</b> apartment" };
执行结果
A very nice apartment A <b>very nice</b> apartment注意了
使用
{{:description}}显示的内容是
A very nice apartment
而使用
{{>description}}显示的是
A <b>very nice</b> apartment
总结:{{> ...}}是转义过后的结果。而{{: ...}}显示的是html结果
JsRender {{> ...}} 与{{: ...}}的区别
原文:http://my.oschina.net/cng1985/blog/510926