<!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" />
</head>
<body>
<a href="../demos.html">JsRender Demos</a><br /> <h3>Accessing paths</h3> <script id="peopleTemplate" type="text/x-jsrender"> <b>{{:#index+1}}:</b> {{>firstName}} {{>lastName}}: <br/>
{{for address tmpl="#addressTemplate"}}{{else}}
Address missing
{{/for}} <div>
Phones:
{{for ~combine(phones, cells)}}
<b>{{>#data}}</b> ({{>#parent.parent.data.firstName}}'s)
{{else}}
{{>#parent.data.firstName}} has no phones or cells
{{/for}} {{!-- or provide an alias to get to firstName from nested content
Phones:
{{for ~combine(phones, cells) ~frstNm=firstName}}
<b>{{>#data}}</b> ({{>~frstNm}}'s)
{{else}}
{{>~frstNm}} has no phones or cells
{{/for}}
--}}
</div> <br/> <i>
{{>firstName}} {{if address && address.street}} {{!-- address may be null or undefined --}}
lives in {{>address.street}}.
{{else}}
has no address...
{{/if}}
</i>
<hr/> </script> <script id="addressTemplate" type="text/x-jsrender">
<div>
{{if street}}
{{>street}}
{{else}}
<i>Somewhere</i> in
{{/if}}
{{>city}}
</div>
</script> <div id="peopleList"></div> <script type="text/javascript">
var people = [
{
firstName: "Pete",
lastName: "Ruffles",
address: {
city: "Bellevue"
},
cells: ["425 666 3455", "425 222 1111"]
},
{
firstName: "Xavier",
lastName: "NoStreet",
phones: ["222 666 3455"],
cells: ["444 666 3455", "999 222 1111"]
},
{
firstName: "Christie",
lastName: "Sutherland",
address: {
street: "222 2nd Ave NE",
city: "Redmond"
}
}
]; $.views.tags({
notLast: function( content ) {
var array = this.parent.data;
return array[ array.length - 1 ] === this.data ? "" : content( this );
}
}); $.views.helpers({
combine: function( arr1, arr2 ) {
return arr1 && arr2 ? arr1.concat(arr2) : arr1 || arr2;
}
}); $( "#peopleList" ).html(
$( "#peopleTemplate" ).render( people )
); </script> </body>
</html>

  

JsRender系列demo(7)compline的更多相关文章

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

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

  2. JsRender系列demo(6)-无名

    <!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. linux网络编程中阻塞和非阻塞socket的区别

    读操作 对于阻塞的socket,当socket的接收缓冲区中没有数据时,read调用会一直阻塞住,直到有数据到来才返 回.当socket缓冲区中的数据量小于期望读取的数据量时,返回实际读取的字节数.当 ...

  2. noip2006T1 能量项链

    最近一直在做noip的题,由于太水一直没有写题解,可是这道题,这道题.啊啊啊啊…… 明明水的要命,调了一节课啊!!我干脆不要搞OI了啊! 特别逗比的错误啊!!!! 代码: #include <c ...

  3. C++使用类型代替枚举量

    自己写的C++类型枚举量,可以使用类型识别取代模板,绑定枚举量和多组调用函数,在调用阶段只要指定某组函数就可以根据枚举量调用相应函数. 代码如下: #ifndef __MYENUM_H__ #defi ...

  4. 一路走过的2013,welcome to 2014

    驻入博客园,还是在大学时,至今没写过一篇博客,一直都是在看人家写的博客.2014 年第一天,就从这一天,开启博客之旅,与大家分享好书,分享技术,结交好朋友. 简单,介绍下自己,大三实习,因为热衷于互联 ...

  5. 重拾C,一天一点点_6

    break与continuecontinue只能用于循环语句goto最常见的用法是终止程序在某些深度嵌套的结构中的处理过程,例如一次跳出两层或多层循环.break只能从最内层循环退出到上一级的循环. ...

  6. 关于华为C8812救砖教程

    问题:华为C8812刷机后,开机显示:---------------------------------------------------------------- Image signature ...

  7. Response.Redirect和Server.Transfer

    今天又比较闲,逛了逛园子,看看asp.net的内容,看到一篇关于这两个的比较: http://www.cnblogs.com/yunfeng8967/archive/2008/03/06/109323 ...

  8. 利用Jmeter做接口测试

    本文作者:大道测试团队-孙云 1.在安装jmeter之前先配置好JDK,再配置jmeter环境变量. 2.启动jmeter 启动jmeter: 双击Jmeter解压路径(apache-jmeter-3 ...

  9. 飞行器的Pitch Yaw Roll概念图解

    前进方向为Z轴 Pitch 升降 绕X轴  对应常见Φ(phi)角: Yaw 偏航 绕Y轴 对应常见θ(theta)角: Roll 翻滚 绕Z轴 对应常见φ(psi)角: 对应表: 参考网址NASA: ...

  10. 查看SQL Server 备份信息

    RESTORE HEADERONLY FROM DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQL2008\MSSQL\Back ...