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. 【概率dp】C. Race to 1 Again

    https://www.bnuoj.com/v3/contest_show.php?cid=9146#problem/C [题意] 给定一个数D,每次随机选取这个数的一个因子x得到新的数D=D/x,知 ...

  2. android去除标题栏和状态栏(全屏)

    转--http://www.eoeandroid.com/thread-66555-1-1.html 在开发中我们经常需要把我们的应用设置为全屏,这里我所知道的有俩中方法,一中是在代码中设置,另一种方 ...

  3. Apache 文件根目录设置修改方法 (Document Root)

    最近在学习WordPress,使用appServ 在windows上搭建Php开发环境 在网上查找到的关于修改Apache服务器根目录的资料,对比学习,再此记录 在安装 Apache 时,系统会给定一 ...

  4. Java操作XML牛逼利器JDOM&DOM4J

    JDOM  JDOM 是一种使用 XML(标准通用标记语言下的一个子集) 的独特 Java 工具包,用于快速开发 XML 应用 程序. JDOM 官方网站:http://www.jdom.org/ 利 ...

  5. Codeforces Round #291 (Div. 2) B. Han Solo and Lazer Gun

    因为是x,y均为整数因此对于同一直线的点,其最简分数x/y是相同的(y可以为0,这里不做除法)于是将这些点不断求最简分数用pair在set中去重即可. #include <cmath> # ...

  6. A. Link/Cut Tree--cf614A ()

    这个题卡精度了  刚开始是2的57次方都已经有误差了  不知道怎么弄 后来加个求余就好了 #include<stdio.h> #include<math.h> #include ...

  7. Unique Binary Search Trees(dp)

    Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For examp ...

  8. Topcoder SRM 657DIV2

    前言: 像我这样一直在DIV2的弱菜..不知道说什么了. A:一定判断有8个‘R’,每行 每列只有一个 B题:大概是  int E,int EM,int M,int MH,int H 然后EM可以给值 ...

  9. Codeforces 920E(补图BFS)

    题意: n(n<=200000)个点的完全图删去了m(m<=200000)条边,求剩下图的连通分量. 分析: 将未访问过的点用一个链表串起来 仍旧进行BFS,每次BFS扩展一个点u的时候, ...

  10. loj6172 Samjia和大树(树形DP+找规律)

    题目: https://loj.ac/problem/6172 分析: 首先容易得出这样的dp式子 然后发现后面那个Σ其实是两段区间,可以用总和减去中间一段区间表示,所以只要维护个前缀和就ok了 这样 ...