JsRender {{> ...}} 与{{: ...}}的区别

<!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)