JsRender系列demo(6)-无名
<!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>Template composition. Using external templates for block tags, such as {{for}} and {{if}}.</h3> <script id="movieTemplate" type="text/x-jsrender">
<tr>
<td>{{include tmpl="#headerTemplate"/}}</td>
<td>
{{for languages tmpl="#columnTemplate"/}}
</td>
<td>
{{for languages tmpl=tmpl/}}
</td>
<td>
{{for languages tmpl='#conditionalTemplate'/}}
</td>
{{include tmpl="#sectionWrapperTemplate"}}
{{>title}}
{{/include}}
<td>
{{for languages tmpl='#indexWrapperTemplate'}}
<b>{{>name}}</b>
{{/for}}
</td>
</tr>
</script> <script id="headerTemplate" type="text/x-jsrender">
<td>{{>title}}</td>
</script> <script id="sectionWrapperTemplate" type="text/x-jsrender">
<td>Section: <em>{{include tmpl=#content/}}</em></td>
</script> <script id="columnTemplate" type="text/x-jsrender">
<div>
<em>{{>name}}</em>
</div>
</script> <script id="rowTemplate" type="text/x-jsrender">
<span>
<b>{{>name}}</b>
</span>
</script> <script id="conditionalTemplate" type="text/x-jsrender">
{{if name.charAt(0)==='E' tmpl='#rowTemplate'}}
{{else tmpl='#columnTemplate'}}
{{/if}}
</script> <script id="indexWrapperTemplate" type="text/x-jsrender">
<div>
{{:#index}}:
{{include tmpl=#content/}}
</div>
</script> <table>
<thead><tr><th>Synopsis</th><th>Fixed Template</th><th>Template specified in data</th><th>Conditional Template</th><th>Wrapper Template</th><th>Repeating Wrapper Template</th></tr></thead>
<tbody id="movieList"></tbody>
</table> <script type="text/javascript"> var movies = [
{
title: "Meet Joe Black",
languages: [
{ name: "English" },
{ name: "French" }
],
tmpl: "#columnTemplate"
},
{
title: "Eyes Wide Shut",
languages: [
{ name: "French" },
{ name: "Esperanto" },
{ name: "Spanish" }
],
tmpl: "#rowTemplate"
},
{
title: "The Inheritance",
languages: [
{ name: "English" },
{ name: "German" }
],
tmpl: "#columnTemplate"
}
]; $( "#movieList" ).html(
$( "#movieTemplate" ).render( movies )
); </script> </body>
</html>
JsRender系列demo(6)-无名的更多相关文章
- JsRender系列demo(9)自定义函数
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...
- JsRender系列demo(7)compline
<!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery.j ...
- JsRender系列demo(5) for else
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...
- JsRender系列demo(4)-if else
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...
- JsRender系列demo(3)-自定义容器
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...
- JsRender系列demo(2)多模板-template
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...
- JsRender系列demo(1)-insert-data
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...
- JsRender系列-11
<!DOCTYPE html> <html> <head> <script type="text/javascript" src=&quo ...
- JsRender系列demo-10
<!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery.j ...
随机推荐
- DataGrid实现逻辑分页
在ASP.NET内建提供的所有数据排列控件中,只有DataGrid数据控件是提供数据分页功能的.DataReapter数据控件只能提供一些简单 的.基础的数据重复排列功能,对于一些比较复杂的应用是无能 ...
- linux命令之grep用法介绍
Linux系统中grep命令是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹 配的行打印出来.grep全称是Global Regular Expression Print,表示全局正则表达 ...
- 取代file_get_contents 的一个采集函数
function url_get_content($url=''){ $ch = curl_init(); $timeout = 100; $browser = 'Mozilla/5.0 (Windo ...
- Java 多线程的基本概念
一.线程介绍 多线程同时运行时,单CPU系统实际上是分给每个线程固定的时间片,用这种方式使得线程“看起来像是并行的”.在多CPU系统中,每个CPU可以单独运行一个线程,实现真正意义上的并行,但是如果线 ...
- Oracle中排序列中值相同引发的问题(译)
This queston came up on the Oracle newsgroup a few days ago: 这个问题在Oracle的新闻中心被提出了一段时间: I have a tabl ...
- js中substring和substr的用法比较
推荐使用substring 方法 stringObject.substring(start,stop) stringObject.substr(start,length) 定义和用法 提取 ...
- referenceerror wx is not defined 微信JsSdk开发
如果你和我一样遇到了“referenceerror wx is not defined”错误,很有可能是jweixin-1.0.0.js与你其它某js冲突. 解决办法: <script type ...
- 使用jQuery获取GridView的数据行的数量
一个同事在群里抛出了上述的问题,另一个同事给出了答案,试了一下,还不错.贴出代码和效果图: <html xmlns="http://www.w3.org/1999/xhtml" ...
- 小课堂Week9 例外处理设计的逆袭Part2
小课堂Week9 例外处理设计的逆袭Part2 今天继续阅读<例外处理设计的逆袭>这本书,我们先看两个案例: 案例1 问:如果要设计一个依据学号到数据库中查询学生资料的函数,当找不到符合条 ...
- python杂记-6(time&datetime模块)
#!/usr/bin/env python# -*- coding: utf-8 -*-import timeprint(time.clock())##返回处理器时间,3.3开始已废弃 , 改成了ti ...