<!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)-无名的更多相关文章

  1. JsRender系列demo(9)自定义函数

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  2. JsRender系列demo(7)compline

    <!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery.j ...

  3. JsRender系列demo(5) for else

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  4. JsRender系列demo(4)-if else

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  5. JsRender系列demo(3)-自定义容器

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  6. JsRender系列demo(2)多模板-template

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  7. JsRender系列demo(1)-insert-data

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  8. JsRender系列-11

    <!DOCTYPE html> <html> <head> <script type="text/javascript" src=&quo ...

  9. JsRender系列demo-10

    <!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery.j ...

随机推荐

  1. score

    #include<iostream> using namespace std; class student{ public: int Input() { ;i<;i++) { cou ...

  2. search help 概述

    所谓search help 就是在前台调出一个query 得到一个value list 让用户选择需要的值 我们要做的就是给某些表/视图 设计一个可供查询的query 然后把这个query绑定到需要的 ...

  3. 深度模拟java动态代理实现机制系类之三

    这里的内容就比较复杂了,要实现的是对任意的接口,对任意指定的方法,以及对任意指定的代理类型进行代理,就更真实的模拟出java虚拟机的动态代理机制 罗列一下这里涉及的类.接口之间的关系,方便大家学习.1 ...

  4. 有趣的checkbox动画切换状态(支付宝转账成功显示)--第三方开源--AnimCheckBox

    这个很有趣的指标通过AnimCheckBox实现,下载地址:https://github.com/lguipeng/AnimCheckBox 代码: activity_main.xml: <Re ...

  5. TClientDataSet中关于TField、TFieldDef动态创立字段的应用

    //使用 TFieldDef 建表: begin with ClientDataSet1.FieldDefs do begin Add('Name' , ftString, 12, True); { ...

  6. ActiveMQ之TemporaryQueue和TemporaryTopic

    TemporaryQueue和TemporaryTopic,从字面上就可以看出它们是“临时”的目的地.可以通过Session来创建,例如: TemporaryQueue replyQueue = se ...

  7. 常见前端面试题之HTML/CSS部分

    转自http://www.cnblogs.com/jscode/archive/2012/07/10/2583856.html Doctype是什么?如何触发严格模式与混杂模式模式?区分它们有何意义? ...

  8. 开发一个iOS应用没有那么容易

    导读:这是来自新加坡的 iOS 开发者 Kent Nguyen 发表在1月底的一篇博文.这篇吐槽文在 iOS 开发圈子里流传甚广,从原文150多个评论就可见一斑,现翻译如下. 让我们开门见山吧:做一个 ...

  9. left edge algorithm.

    今天在看GCPC 2013 的时候,遇到了一个简单的任务分配的题目. 即给定一系列任务[l,r], 每个人不能同时做两个, 最多需要几个人来完成? 这个问题的一个标准解法是对所有l,r排序,然后遇到l ...

  10. PHP获取mysql数据表的字段名称和详细信息的方法

    首先我们需要了解下查询MySQL数据库/表相关信息的SQL语句: 代码如下: SHOW DATABASES                                //列出 MySQL Serv ...