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. 【数学】codeforces B. The Golden Age

    http://codeforces.com/contest/813/problem/B [题意] 满足n=x^a+y^b的数字为不幸运数字,a,b都是非负整数: 求闭区间[l,r]上的最长的连续幸运数 ...

  2. 选课(codevs 1378)

    题目描述 Description 学校实行学分制.每门的必修课都有固定的学分,同时还必须获得相应的选修课程学分.学校开设了N(N<300)门的选修课程,每个学生可选课程的数量M是给定的.学生选修 ...

  3. Linux中命令选项及参数简介

    登录Linux后,我们就可以在#或$符后面去输入命令,有的时候命令后面还会跟着“选项”(英文options)或“参数”(英文arguments).即Linux中命令格式为: command [opti ...

  4. mysql.bat

    cls  @echo off :设置窗口字体颜色 color 0a  :设置窗口标题 TITLE MySQL管理程序    call :checkAdmin    goto menu :菜单 :men ...

  5. java验证身份证号码是否有效源代码

    原文:http://www.open-open.com/code/view/1420373343171 1.描述 用java语言判断身份证号码是否有效,地区码.出身年月.校验码等验证算法 2.源代码 ...

  6. IOS开发 APP提交程序上传流程

    由于苹果的机制,在非越狱机器上安装应用必须通过官方的App Store,开发者开发好应用后上传App Store,也需要通过审核等环节.AppCan作为一个跨主流平台的一个开发平台,也对ipa包上传A ...

  7. 【APUE】信号量、互斥体和自旋锁

    http://www.cnblogs.com/biyeymyhjob/archive/2012/07/21/2602015.html http://blog.chinaunix.net/uid-205 ...

  8. sudo 用户添加

    sudo 用户添加 /etc/sudoers 在 ## Allow root to run any commands anywhere root    ALL=(ALL)   ALL 下面加上 xxx ...

  9. OCR简介及使用

    OCR (Optical Character Recognition,光学字符识别)是指电子设备(例如扫描仪或数码相机)检查纸上打印的字符,通过检测暗.亮的模式确定其形状,然后用字符识别方法将形状翻译 ...

  10. Unity Critter地图导出到server配置

    普通情况下,从Critter导出的地图会与Unity自带的Navigation洪培出的地图会有比較大的差异.须要耐心调整Critter的參数才干够. 以下是我调的參数,与Unity导出的地图基本相似. ...