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. ajax请求数据之后在已经有的数据前面打对勾的方法

    今天遇到这么一个需求: 选择一部分人,在点击确定的时候添加到对应的div中,也就是添加到对应的表单下面,当再次查询的时候需要在已经选过的人的复选框前面打伤对勾.

  2. [Android] 随时拍图像处理部分总结及源码分享

    http://blog.csdn.net/eastmount/article/details/45492065#comments [Android] 图像各种处理系列文章合集 http://blog. ...

  3. HDU 6278 主席树(区间第k大)+二分

    Just h-index Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 132768/132768 K (Java/Others)To ...

  4. 定制 ArcEngine 要素编辑工具

    来自:http://blog.sina.com.cn/s/blog_4d780fc10101d2d5.html 先初步了解到大概用到的下面的接口和类: IEngineEditor IEngineEdi ...

  5. jenkins节约硬盘空间的几个办法

    jenkins真是费硬盘和内存,我们先聊聊硬盘问题怎么解决: 1.不要保留太多的构建记录.发布包数量 相关描述如下:取最先匹配进行执行 2.构建完,删除吧

  6. Codeforces Round #258 (Div. 2) B. Sort the Array(简单题)

    题目链接:http://codeforces.com/contest/451/problem/B --------------------------------------------------- ...

  7. 【Nginx】如何使用http配置

    处理http配置项可以分为下面4个步骤: 1)创建数据结构用于存储配置项对应的参数 2)设定配置项在nginx.conf中出现时的限制条件与回调方法 3)实现第2步中的回调方法,或者使用Nginx框架 ...

  8. office outlook 無法開啟 outlook 視窗

    例如[無法啟動Microsoft Office Outlook.無法開啟Outlook 視窗.] 1.啟動 Outlook 安全模式outlook.exe /safe2.清除並重新產生目前設定檔的功能 ...

  9. VB6 如何自定义代码字体和支持鼠标滚轮

    1 点击工具-选项-编辑器格式,把代码改成需要的字体和大小.(一般微软雅黑,16号字体比较好)   2 从以下网站下载VB6增强工具,可以支持鼠标滚轮代替右侧滚动条查看代码,按F3还可以切换代码窗口和 ...

  10. sql跟踪及tkprof使用

    简述 在oracle数据库中,awr是关于数据库系统总体的负载情况和运行情况的报告.而当系统负载都显示正常,而client运行某些动作响应非常慢,或者某些终端连接的会话运行缓慢或异常时,就须要用到会话 ...