JTemplate学习(四)
注释、自定方法、模板嵌套子模板、循环输出不同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学习(四)的更多相关文章
- TweenMax动画库学习(四)
		
目录 TweenMax动画库学习(一) TweenMax动画库学习(二) TweenMax动画库学习(三) Tw ...
 - SVG 学习<四> 基础API
		
目录 SVG 学习<一>基础图形及线段 SVG 学习<二>进阶 SVG世界,视野,视窗 stroke属性 svg分组 SVG 学习<三>渐变 SVG 学习<四 ...
 - Android JNI学习(四)——JNI的常用方法的中文API
		
本系列文章如下: Android JNI(一)——NDK与JNI基础 Android JNI学习(二)——实战JNI之“hello world” Android JNI学习(三)——Java与Nati ...
 - SCARA——OpenGL入门学习四(颜色)
		
OpenGL入门学习[四] 本次学习的是颜色的选择.终于要走出黑白的世界了~~ OpenGL支持两种颜色模式:一种是RGBA,一种是颜色索引模式. 无论哪种颜色模式,计算机都必须为每一个像素保存一些数 ...
 - ZigBee学习四 无线+UART通信
		
ZigBee学习四 无线+UART通信 1) 协调器编程 修改coordinator.c文件 byte GenericApp_TransID; // This is the unique messag ...
 - (转)SpringMVC学习(四)——Spring、MyBatis和SpringMVC的整合
		
http://blog.csdn.net/yerenyuan_pku/article/details/72231763 之前我整合了Spring和MyBatis这两个框架,不会的可以看我的文章MyBa ...
 - Spring Boot 项目学习 (四) Spring Boot整合Swagger2自动生成API文档
		
0 引言 在做服务端开发的时候,难免会涉及到API 接口文档的编写,可以经历过手写API 文档的过程,就会发现,一个自动生成API文档可以提高多少的效率. 以下列举几个手写API 文档的痛点: 文档需 ...
 - Expression Blend学习四控件
		
原文:Expression Blend学习四控件 Expression Blend制作自定义按钮 1.从Blend工具箱中添加一个Button,按住shift,将尺寸调整为125*125; 2.右键点 ...
 - day 83  Vue学习四之过滤器、钩子函数、路由、全家桶等
		
Vue学习四之过滤器.钩子函数.路由.全家桶等 本节目录 一 vue过滤器 二 生命周期的钩子函数 三 vue的全家桶 四 xxx 五 xxx 六 xxx 七 xxx 八 xxx 一 Vue的过滤 ...
 - Python基础学习四
		
Python基础学习四 1.内置函数 help()函数:用于查看内置函数的用途. help(abs) isinstance()函数:用于判断变量类型. isinstance(x,(int,float) ...
 
随机推荐
- 常用模块:hashlib,subprocess,configparser。
			
一 hashlib模块 那么我们前面学习数据类型的时候,也讲了hash,可变类型不可hash:不可变类型可hash. 我们知道hash是一种算法,接收传入的内容经过运算之后得到一个hash值,我们可 ...
 - sweetalert插件使用
			
内容: 1.插件介绍 2.插件使用 1.插件介绍 SweetAlert是一个JS插件,能够完美替代JS自带的alert弹出框,并且功能强大,设计优美 使用这个很方便,推荐使用这个插件来写alert s ...
 - tensorflow data's save and load
			
note: if you'll load data,the data shape should be similar with saved data's shape. -- 中式英语,天下无敌 ...
 - Django高级admin续
			
ModelAdmin对象 ModelAdmin类是模型在Admin界面中的表示形式 定义:定义一个类,继承于admin.ModelAdmin,注册模型时使用这个类 class HeroAdmin(ad ...
 - snmp简单识记
			
免费snmp探测 http://webluker.com/webtools/snmp snmp简单网络管理协议(simple network management protocol)前身时sgmp简单 ...
 - 1. myeclipse设置jsp默认打开方式为jsp Editor
			
1.windows - preferences - General - Editors - File Associations
 - C# IIS 服务器 HTTP 错误 500.21 - Internal Server Error 解决办法
			
<1> 管理员身份启动控制台 <2> 输入 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe ...
 - linux的基础
			
vmtools 的安装:作用 ——>共享linux和windows的文件夹 reboot 重启 远程登录 : 远程登录时要打开sshd(监视22端口) 怎么设施sshd: 打开远端,输入setu ...
 - Putty全屏/退出全屏快捷键
 - 15 MySQL--索引
			
索引: http://www.cnblogs.com/linhaifeng/articles/7356064.html http://www.cnblogs.com/linhaifeng/articl ...