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. poj3468区间延迟更新模板题

    #include<stdio.h> #include<string.h> #define N 100000 struct st{  int x,y;  __int64 yanc ...

  2. [转]制作一个64M的U盘启动盘(mini linux + winpe +dos toolbox)

    自己动手定制winpe+各类dos工具箱U盘启动盘+minilinux 由于一个64M老U盘,没什么用,拿来发挥余热.如果U盘够大,可以使用功能更强大的mini linux和带更多工具的winpe.这 ...

  3. 在后台根据单据标识构建单据的DynamicObject,然后调用BOS的保存服务保存单据。

    var bussnessInfo = Kingdee.BOS.ServiceHelper.MetaDataServiceHelper.GetFormMetaData(this.Context, &qu ...

  4. 编译.net .net Core程序 代码,仅做备份

    //创建一个ProcessStartInfo对象 使用系统shell 指定命令和参数 设置标准输出 //编译.net core项目 var psi = new ProcessStartInfo(&qu ...

  5. NOIP2017 酱油记

    Day0: 怀着激动无比的小心情,坐上了学校的校车. 然后司机在某个小县城迷路了,迷路了两个多小时.... 来到酒店,去吃了几把鸡,没见到鸡屁股... 洗了个澡早早睡了.. Day1: 一早被闹铃叫醒 ...

  6. Java并发编程,3分分钟深入分析volatile的实现原理

    volatile原理 volatile简介 Java内存模型告诉我们,各个线程会将共享变量从主内存中拷贝到工作内存,然后执行引擎会基于工作内存中的数据进行操作处理. 线程在工作内存进行操作后何时会写到 ...

  7. 转:ORACLE存储过程笔记1----基本语法(以及与informix的比较)

    一.基本语法(以及与informix的比较)   create [or replace] procedure procedure_name (varible {IN|OUT|IN OUT} type) ...

  8. 【TFS 2017 CI/CD系列 - 02】-- Build篇

    .创建Build 登录TFS,在现有的[Projects]中选择一个需要要创建Build的Project,点击[Build & Release]跳转页面 在新页面中选择[Builds]选项卡, ...

  9. how to read openstack code: service plugin

    We have learned core plugin, service plugin and extension in last post. Now let`s review: Core Plugi ...

  10. stl 之set图解

    使用set或multiset之前,必须增加头文件<set> Set.multiset都是集合类,区别在与set中不同意有反复元素,multiset中同意有反复元素. sets和multis ...