注释、自定方法、模板嵌套子模板、循环输出不同class

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<!-- saved from url=(0043)http://jtemplates.tpython.com/example4.html -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="Scripts/jTemplates/example/jquery.js"></script>
<script type="text/javascript" src="Scripts/jTemplates/jquery-jtemplates.js"></script>
<title>jTemplates</title> <script type="text/javascript">
// data for testing
$(document).ready(function () {
var data = {
name: 'User list',
list_id: 4,
table: [
{ id: 1, name: 'Anne', age: 22, mail: 'anne@domain.com' },
{ id: 2, name: 'Amelie', age: 24, mail: 'amelie@domain.com' },
{ id: 3, name: 'Polly', age: 18, mail: 'polly@domain.com' },
{ id: 4, name: 'Alice', age: 26, mail: 'alice@domain.com' },
{ id: 5, name: 'Martha', age: 25, mail: 'martha@domain.com' }
],
toString: function () {
return this.name.bold() + ' (count: ' + this.table.length + ')';
}
}; // attach the template
$("#result1").setTemplateElement("template"); // process the template
$("#result1").processTemplate(data); //{**} 注释
//
});
</script> <style type="text/css">
.jTemplatesTest {
background: #DDD;
border: 1px solid #000;
margin: 2em;
width: 480px;
} .jTemplatesTest * {
padding: 4px;
margin: 2px auto;
} .jTemplatesTest td, tr {
border: 1px solid black;
} .bcEEC {
background: #EEC;
} .bcCEE {
background: #CEE;
}
</style>
</head> <body style="zoom: 1;"> <!-- Template content (Valid XHTML 1.1) -->
<p style="display: none">
<textarea id="template" rows="0" cols="0"><!--
{*主模板*}
{#template MAIN}
{* this is a comment *}
{$T.toString()} {* $T == $T.toSource() *}
<table>
{#foreach $T.table as record}
{#include ROW root=$T.record}{*为子模板指定数据源,循环填充数据*}
{#/for}
</table>
{#/template MAIN} {*嵌套子模板*}
{#template ROW}
<tr class="{#cycle values=['bcEEC','bcCEE']}">{*循环输出*}
<td>{$T.name}</td>
<td>{$T.mail}</td>
</tr>
{#/template ROW}
--></textarea>
</p> <!-- Output elements -->
<div id="result1" class="jTemplatesTest">
</div>
</body>
</html>

JTemplate学习(四)的更多相关文章

  1. TweenMax动画库学习(四)

    目录            TweenMax动画库学习(一)            TweenMax动画库学习(二)            TweenMax动画库学习(三)            Tw ...

  2. SVG 学习<四> 基础API

    目录 SVG 学习<一>基础图形及线段 SVG 学习<二>进阶 SVG世界,视野,视窗 stroke属性 svg分组 SVG 学习<三>渐变 SVG 学习<四 ...

  3. Android JNI学习(四)——JNI的常用方法的中文API

    本系列文章如下: Android JNI(一)——NDK与JNI基础 Android JNI学习(二)——实战JNI之“hello world” Android JNI学习(三)——Java与Nati ...

  4. SCARA——OpenGL入门学习四(颜色)

    OpenGL入门学习[四] 本次学习的是颜色的选择.终于要走出黑白的世界了~~ OpenGL支持两种颜色模式:一种是RGBA,一种是颜色索引模式. 无论哪种颜色模式,计算机都必须为每一个像素保存一些数 ...

  5. ZigBee学习四 无线+UART通信

    ZigBee学习四 无线+UART通信 1) 协调器编程 修改coordinator.c文件 byte GenericApp_TransID; // This is the unique messag ...

  6. (转)SpringMVC学习(四)——Spring、MyBatis和SpringMVC的整合

    http://blog.csdn.net/yerenyuan_pku/article/details/72231763 之前我整合了Spring和MyBatis这两个框架,不会的可以看我的文章MyBa ...

  7. Spring Boot 项目学习 (四) Spring Boot整合Swagger2自动生成API文档

    0 引言 在做服务端开发的时候,难免会涉及到API 接口文档的编写,可以经历过手写API 文档的过程,就会发现,一个自动生成API文档可以提高多少的效率. 以下列举几个手写API 文档的痛点: 文档需 ...

  8. Expression Blend学习四控件

    原文:Expression Blend学习四控件 Expression Blend制作自定义按钮 1.从Blend工具箱中添加一个Button,按住shift,将尺寸调整为125*125; 2.右键点 ...

  9. day 83 Vue学习四之过滤器、钩子函数、路由、全家桶等

    Vue学习四之过滤器.钩子函数.路由.全家桶等   本节目录 一 vue过滤器 二 生命周期的钩子函数 三 vue的全家桶 四 xxx 五 xxx 六 xxx 七 xxx 八 xxx 一 Vue的过滤 ...

  10. Python基础学习四

    Python基础学习四 1.内置函数 help()函数:用于查看内置函数的用途. help(abs) isinstance()函数:用于判断变量类型. isinstance(x,(int,float) ...

随机推荐

  1. 库、教程、论文实现,这是一份超全的PyTorch资源列表(Github 2.2K星)

    项目地址:https://github.com/bharathgs/Awesome-pytorch-list 列表结构: NLP 与语音处理 计算机视觉 概率/生成库 其他库 教程与示例 论文实现 P ...

  2. 基于Linux的Samba开源共享解决方案测试(五)

    对于客户端的网络监控如图: 双NAS网关50Mb码率视音频文件的稳定写测试结果如下: 100Mb/s负载性能记录 NAS网关资源占用 稳定写 稳定写 CPU空闲 内存空闲 网卡占用 NAS1 16个稳 ...

  3. mysql5.6下载&安装

    官网下载即可: mysql-installer-community-5.6.25.0.msi 安装: 1. 2. 3.在这里我们需要从安装程序提供的可安装的产品(Products)中选择我们需要的my ...

  4. [Flutter] TextField 中只允许输入合法的小数

    的Flutter的TextField中,我们可以通过设置inputFormatters来过滤和限制输入的内容. 下面是一个自定义的 TextInputFormatter,可以限制用户只能输入有效的整数 ...

  5. UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 120: illegal multibyte sequence

    UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 120: illegal multibyte sequence f ...

  6. 自动化运维工具 SaltStack 在云计算环境中的实践

    http://www.talkwithtrend.com/Article/218473

  7. 数据库中的html在页面上显示

    在ASP页面中,动态显示html格式的数据的方法如下: .aspx文件: <div id="divBox" runat="server"></ ...

  8. SQL 2012 分页取数据

    ,), data int ) select * from t1 row rows only create clustered index t1c on t1(id) declare @i int ) ...

  9. Delphi 浏览器WebBrowser

    WebBrowser1.Navigate(URL); while WebBrowser1.busy do Application.ProcessMessages; while WebBrowser1. ...

  10. SQL Server 2005 无法连接到WMI提供程序 无法执行 SQL Server 系统配置检查器

    无法连接到WMI提供程序.你没有权限或者该服务器无法访问/cannot connect to WMI provider. You do not have permission or the--由于计算 ...