JsRender系列demo-10

时间:2022-02-21 16:14:19
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
<script src="../../jsrender.js" type="text/javascript"></script>
<link href="../resources/demos.css" rel="stylesheet" type="text/css" /> <link href="../resources/movielist.css" rel="stylesheet" type="text/css" />
</head>
<body>
<a href="../demos.html">JsRender Demos</a><br /> <h3>Comparison tests</h3> <pre>
{{if !(languages && languages.length)}}...{{/if}} {{if languages==null}}...{{/if}}
</pre> <!--================ Demo ================--> <script id="movieTemplate" type="text/x-jsrender">
<tr>
<td>{{>title}}</td>
<td>
{{if !(languages && languages.length) tmpl="#messageTmpl"/}}
</td>
<td>
{{if languages==null tmpl="#messageTmpl"/}}
</td>
</tr>
</script> <script id="messageTmpl" type="text/x-jsrender">
<b>Warning:</b> <em>No alternate languages</em>
</script> <table>
<thead><tr><th>Title</th><th>{{if !(languages && languages.length)}}</th><th>{{if a==null}}</th></tr></thead>
<tbody id="movieList"></tbody>
</table> <script type="text/javascript">
var movies = [
{
title: "Meet Joe Black",
languages: null
},
{
title: "The Mighty",
languages: []
},
{
title: "Eyes Wide Shut",
languages: [
{ name: "French" },
{ name: "German" },
{ name: "Spanish" }
]
}
]; $( "#movieList" ).html(
$( "#movieTemplate" ).render( movies )
); </script> </body>
</html>