include用于嵌入字模板

{{include 'template_name'}}

子模板 默认共享当前的数据 也可以自己指定数据

{{include 'template_name' template_data}}

demo1

html

<div id="content5"></div>

template

<script type="text/html" id="test6">
<ul>
{{each content}}
<li>{{$value}}</li>
{{/each}}
</ul>
</script>
<script id="test5" type="text/html">
<div>
<h3>test5:{{title}}</h3>
<div>{{include 'test6' list}}</div>
</div>
</script>

js

var data1 = {
aa:"ewewew",
title : 'HELLO WORLD',
isAdmin : true,
list :{
content: ['新闻','军事','历史','政治']
} };
var html5=template('test5',data1);
document.getElementById("content5").innerHTML=html5;

demo2

html

<div id="aa"></div>

template:

<script type='text/html' id='test3'>
<ul>
{{each list}}
<li>
{{$value}}
</li>
{{/each}}
</ul>
</script>
<script type='text/html' id='test1'>
<ul>
{{each content}}
<li>
<div>{{$value.title}}</div>
<div>{{include 'test3' $value}}</div>
</li>
{{/each}}
</ul>
</script> <script type='text/html' id='test2'>
<h3>{{title}}</h3>
<ul>
{{each list}}
<li>{{include 'test1' $value}}</li>
{{/each}}
</ul> </script>

js

<script>

    var data = {
title: "this is my first include demo",
list: [
{content: [
{list: ['新闻', '军事', '历史', '政治'], title: 'aa-1-1'},
{list: ['新闻', '军事', '历史', '政治'], title: 'aa-1-2'}
]},
{content:[
{list: ['新闻', '军事', '历史', '政治'], title: 'aa-2-1'},
{list: ['新闻', '军事', '历史', '政治'], title: 'aa-1-1'}
]
}]
};
var html = template('test2', data);
document.getElementById('aa').innerHTML = html;
</script>

artemplate include的更多相关文章

  1. 浅谈JSP中include指令与include动作标识的区别

    JSP中主要包含三大指令,分别是page,include,taglib.本篇主要提及include指令. include指令使用格式:<%@ include file="文件的绝对路径 ...

  2. Entity Framework 6 Recipes 2nd Edition(13-9)译 -> 避免Include

    问题 你想不用Include()方法,立即加载一下相关的集合,并想通过EF的CodeFirst方式实现. 解决方案 假设你有一个如Figure 13-14所示的模型: Figure 13-14. A ...

  3. error RC1015: cannot open include file 'afxres.h' 解决办法

    在为WindowsPhone8程序添加本地化的过程中遇到这个问题: 问题原因就是afxres.h文件缺失,下载它,放到VS安装目录下的VS\include目录下就可以了(选择目录的时候注意对应对版本) ...

  4. Mybatis常用总结:参数,返回,执行sql,include等

    1.参数注入1.1用#{0},#{1}的形式,0代表第一个参数,1代表第二个参数 public List<RecordVo> queryList(String workerId, Inte ...

  5. jsp中的@include与jsp:include区别详解

    1 前言 搞java开发的人也许都知道在jsp中引入项目中其他文件有如下两种方式 <%@include file="xxx.jsp"%> <jsp:include ...

  6. JSP中编译指令include与动作指令include的区别

    include指令是编译阶段的指令,即include所包含的文件的内容是编译的时候插入到JSP文件中,JSP引擎在判断JSP页面未被修改, 否则视为已被修改.由于被包含的文件是在编译时才插入的,因此如 ...

  7. C/C++ 中的include

    当需要使用已有的方法或库时, 可以将它们的头文件#include进来. #include会在preprocess过程中被替换成它包含的代码. 头文件中包含了需要使用的函数/变量的声明. 当然声明与定义 ...

  8. 织梦多语言站点,{dede:include filename=''/}引入问题

    织梦模板include插入非模板目录文件出现"无法在这个位置找到"错误的解决办法 以下是dede V55_UTF8 查dede include标签手册 (3) include 引入 ...

  9. PHP 站点相对包含,路径的问题解决方法(include,require)

    以前看了,很多框架,基本上很少使用相对路径包含.而一般很多做php web站点,喜欢用相对路径. 认为这样,无论目录放到那里. 只要跟另外目录关系一致.那么就不会出现问题.如果一个站点,一般都认为,如 ...

随机推荐

  1. SQL SERVER 2012 第三章 使用INSERT语句添加数据

    INSERT [TOP (<expression>) [PERCENT] [INTO] <tabular object>[(column list)][OUTPUT <o ...

  2. HDU 6395 分段矩阵快速幂 HDU 6386 建虚点+dij

    http://acm.hdu.edu.cn/showproblem.php?pid=6395 Sequence Time Limit: 4000/2000 MS (Java/Others)    Me ...

  3. F - The Minimum Length

    F - The Minimum Length HUST - 1010 #include<cstdio> #include<cstring> #include<iostre ...

  4. 下载数据到Excel,工具类

    使用反射将model数据下载到Excel中 package test.upload.utils; import java.lang.reflect.Method; import java.math.B ...

  5. 破解电信光猫华为HG8120C关闭路由功能方法

    昨天电信的工作人员来安装了电信的光纤宽带,使用的是华为HG8120C这款光电转换器与路由器一体机 这导致下级路由无法直接使用PPPOE拨号连接到互联网,且无法使用端口映射来实现外网访问 而华为开放给用 ...

  6. Openwrt 安装软件到U盘或硬盘

    http://blog.licess.org/openwrt-install-software-to-udisk-harddisk/ 运行一个多月的DDNAS被结婚来玩的小孩给关了,于是趁机更新了一下 ...

  7. samba.conf (香港中华厨房有限公司实例)

    # Sample configuration file for the Samba suite for Debian GNU/Linux. # # This is the main Samba con ...

  8. C语言必会面试题(3、耶稣有13个门徒,当中有一个就是出卖耶稣的叛徒,请用排除法找出这位叛徒:13人围坐一圈,从第一个開始报号:1,2,3,1,2,3...。凡是报到“3”就退出圈子,...)

    3.耶稣有13个门徒.当中有一个就是出卖耶稣的叛徒,请用排除法找出这位叛徒:13人围坐一圈,从第一个開始报号:1.2,3.1,2,3.... 凡是报到"3"就退出圈子.最后留在圈子 ...

  9. Mybatis加入Ehcache支持

    1.Mybatis默认的缓存配置 MyBatis 包括一个很强大的查询缓存特性,它能够很方便地配置和定制. Mybatis缓存包括全局的缓存和局部的缓存.全局的缓存能够讲主配置文件的setting属性 ...

  10. 游戏server设计的一些感悟

    Author:Echo Chen(陈斌) Email:chenb19870707@gmail.com Blog:Blog.csdn.net/chen19870707 Date:September 30 ...