码迷,mamicode.com
首页 > Web开发 > 详细

JsRender系列demo(4)-if else

时间:2014-07-27 22:18:09      阅读:267      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   java   os   io   cti   html   

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script type="text/javascript" src="scripts/jquery.js"></script>
<script type="text/javascript" src="scripts/jquery-ui.js"></script>
<script type="text/javascript" src="scripts/jsrender.js"></script>
<link href="scripts/demos.css" rel="stylesheet" />
<link href="scripts/movielist.css" rel="stylesheet" />
</head>
<body>
<h3>Using {{if}} and {{else}} to render conditional sections.</h3>

<script type="text/x-jsrender" id="movieTemplate">
<tr>
<td>{{>title}}</td>
<td>{{if languages}}
Alternative languages:<em>{{>languages}}</em>
{{else subtitles}}
Original language only...
<br />
subtitles in <em>{{>subtitles}}</em>
{{else}}
Original version only, without subtitles.
{{/if}}</td>
</tr>
</script>
 

<script type="text/javascript">
var movies = [
{
title: "Meet Joe Black",
languages: "English and French",
subtitles: "English"
},
{
title: "Eyes Wide Shut",
subtitles: "French and Spanish"
},
{
title: "The Mighty"
},
{
title: "City Hunter",
languages: "Mandarin and Chinese"
}
];

$("#movieList").html($("#movieTemplate").render(movies));
</script>
  

</body>
</html>

  

JsRender系列demo(4)-if else,布布扣,bubuko.com

JsRender系列demo(4)-if else

标签:style   blog   http   java   os   io   cti   html   

原文地址:http://www.cnblogs.com/alphafly/p/3871490.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!