art-template是一款较通用的前端模板引擎。

简单的使用方法如下:

具备3个要素

1)模板

    <script type="text/template" id="tpl">
<p>我是一头{{animal}}</p>
</script>

2)引入插件

    <script src="./template-web.js"></script>

3)调用插件

var html = template('tpl', {animal:"老虎" });
console.log(html);

------------------------------------------------------------------------------------------------------

关于在模板中填充数据注意点:

这个地方有一点需要注意:如果传入给template第二个参数的是一个没有次级对象的单层级对象,模板中只要包含属性名就好, 如

{animal:"老虎"} => {{animal}}

{animals:{"cat":"老虎", "dog":"狮子"}} => {{animals.cat}} | {{animals.dog}}

------------------------------------------------------------------------------------------------------

集中基础简单的应用:

  •  循环

模板中的写法:

{{each target}}
{{$index}} {{$value}}
{{/each}}

传入template的数据的格式

{"target":["aaa","bbb","ccc"]}

{"target":{a:"aaa",v:"bbb",c:"ccc"}
  •  条件

模板中的写法:

{{if age == "21"}}
....
{{else if age == "23"}}
....
{{/if}}

传入template的数据的格式

{"age":"23"}
  •  原文输入(即不将 < > / 等符号进行转码输出)
{{@ data }}

  

详细信息可看art-template官网 http://aui.github.io/art-template/zh-cn/

art-template简单使用的更多相关文章

  1. art template前端模板引擎

    偶然看到后台有一段代码 采用的是art template的模板引擎 地址为 http://aui.github.io/artTemplate/ 这段代码很简洁 var html = template( ...

  2. Azure ARM (6) ARM Template简单介绍

    <Windows Azure Platform 系列文章目录>      Azure ARM (1) 概览      Azure ARM (2) 概览      Azure ARM (3) ...

  3. art.template 循环里面分组。

    后台提供给我们一个数组,我们要用模版实现上面的格式输出怎么版呢? 下面就是解决方案: <h2>循环4个一组</h2> <script type="text/ht ...

  4. Codeforces Round #313 B. Gerald is into Art(简单题)

    B. Gerald is into Art time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  5. 利用art.template模仿VUE 一次渲染多个模版

    TypeScript代码 import template = require('art-template/lib/template-web'); interface TemplateBindConfi ...

  6. 利用art.template模仿VUE

    首先先看一下Typescript代码: import template = require('art-template/lib/template-web'); interface TemplateBi ...

  7. js 模板引擎 -Art Template

    一个例子涵盖所有: <!doctype html> <html> <head> <meta charset="UTF-8"> < ...

  8. ES6/ES2015的一些特性的简单使

    1.一些常用的ES6的特性: let, const, class, extends, super, arrow functions, template string, destructuring, d ...

  9. js库之art.dialog

    自适应内容 artDialog的特殊UI框架能够适应内容变化,甚至连外部程序动态插入的内容它仍然能自适应,因此你不必去考虑消息内容尺寸使用它.它的消息容器甚至能够根据宽度让文本居中或居左对齐——这一切 ...

  10. [转] 在React Native中使用ART

    http://bbs.reactnative.cn/topic/306/%E5%9C%A8react-native%E4%B8%AD%E4%BD%BF%E7%94%A8art 前半个月捣腾了一下Rea ...

随机推荐

  1. Python匿名函数/排序函数/过滤函数/映射函数/递归/二分法

    一. lamda匿名函数 为了解决一些简单的需求而设计的一句话函数 # 计算n的n次方 def func(n): return n**n print(func(10)) f = lambda n: n ...

  2. eas之数据融合

    1.如何进行自由融合自由融合无须指定区域,KDTable将根据指定的融合模式,融合相邻且值相等的单元.// 自由行融合table.getMergeManager().setMergeMode(KDTM ...

  3. [luogu2165 AHOI2009] 飞行棋 (枚举)

    传送门 Description 给出圆周上的若干个点,已知点与点之间的弧长,其值均为正整数,并依圆周顺序排列. 请找出这些点中有没有可以围成矩形的,并希望在最短时间内找出所有不重复矩形. Input ...

  4. Tyvj - 1286 - 校门外的树2

    描述 Description 某校大门外长度为L的马路上有一排树,每两棵相邻的树之间的间隔都是1米.我们可以把马路看成一个数轴,马路的一端在数轴0的位置,另一端在L的位置:数轴上的每个整数点,即0,1 ...

  5. Efficient ticket lock synchronization implementation using early wakeup in the presence of oversubscription

    A turn-oriented thread and/or process synchronization facility obtains a ticket value from a monoton ...

  6. Dockerfile分离构建LNMP环境部署wordpress

    最近忙着写自己的项目,也把一个站点的bbs论坛打算迁移到Docker中,测试没发现啥大问题.在单台上面的架构如下:(往后我们也是要讲到compose和swarm调度的慢慢来) 1.首先我们先安装一下d ...

  7. ul,li不能左右居中的问题

    近期帮朋友做一个他们公司的商品站点,用到了曾经学到的html+css技术,当然做站点少不了Javascript和jquery这些..... 这个功能主要实现了导航条里面的条目是居中的.所以声明了ul, ...

  8. uva 10479(找规律+递归)

    题意:有一个初始序列第一个数字是0. 规律是把前一次推出来的每个数字x.先接x个0,然后接x+1. 0 –> 1 –> 02 –> 1003 –> 02110004 那么这个序 ...

  9. 哈理工 oj 2122 旅行(map + 最短路dij算法)

    旅行 Time Limit: 1000 MS Memory Limit: 32768 K Total Submit: 18(6 users) Total Accepted: 3(3 users) Ra ...

  10. KeyEvent 键码值

    A 至 Z 键与 A – Z 字母的 ASCII 码同样: 值 描写叙述 65 A 键 66 B 键 67 C 键 68 D 键 69 E 键 70 F 键 71 G 键 72 H 键 73 I 键 ...