art-template简单使用
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简单使用的更多相关文章
- art template前端模板引擎
偶然看到后台有一段代码 采用的是art template的模板引擎 地址为 http://aui.github.io/artTemplate/ 这段代码很简洁 var html = template( ...
- Azure ARM (6) ARM Template简单介绍
<Windows Azure Platform 系列文章目录> Azure ARM (1) 概览 Azure ARM (2) 概览 Azure ARM (3) ...
- art.template 循环里面分组。
后台提供给我们一个数组,我们要用模版实现上面的格式输出怎么版呢? 下面就是解决方案: <h2>循环4个一组</h2> <script type="text/ht ...
- 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 ...
- 利用art.template模仿VUE 一次渲染多个模版
TypeScript代码 import template = require('art-template/lib/template-web'); interface TemplateBindConfi ...
- 利用art.template模仿VUE
首先先看一下Typescript代码: import template = require('art-template/lib/template-web'); interface TemplateBi ...
- js 模板引擎 -Art Template
一个例子涵盖所有: <!doctype html> <html> <head> <meta charset="UTF-8"> < ...
- ES6/ES2015的一些特性的简单使
1.一些常用的ES6的特性: let, const, class, extends, super, arrow functions, template string, destructuring, d ...
- js库之art.dialog
自适应内容 artDialog的特殊UI框架能够适应内容变化,甚至连外部程序动态插入的内容它仍然能自适应,因此你不必去考虑消息内容尺寸使用它.它的消息容器甚至能够根据宽度让文本居中或居左对齐——这一切 ...
- [转] 在React Native中使用ART
http://bbs.reactnative.cn/topic/306/%E5%9C%A8react-native%E4%B8%AD%E4%BD%BF%E7%94%A8art 前半个月捣腾了一下Rea ...
随机推荐
- python核心编程中的对象值比较VS对象身份比较(转载)
转载地址: https://blog.csdn.net/Mluka/article/details/51076786 在python核心编程第四章中,P69在优化下面这段代码时提出了:对象值比较VS对 ...
- Laravel Cache 缓存使用
导入:use Cache; Cache::put('key', 'value', $minutes); 添加一个缓存 Cache 门面的 get 方法用于从缓存中获取缓存项,如果缓存项不存在,返回 n ...
- 数据库操作(一)DML
1.数据库 数据库可视为电子化的文件柜——存储电子文件的处所,用户可以对文件中的数据进行新增.查询.更新.删除等操作. 所谓“数据库”是以一定方式储存在一起.能与多个用户共享.具有尽可能小的冗余度.与 ...
- js中的数组遍历
js中的数组遍历是项目中经常用到的,在这里将几种方法做个对比. ! for循环:使用评率最高,也是最基本的一种遍历方式. let arr = ['a','b','c','d','e']; for (l ...
- window.open方法被浏览器拦截的处理方式
问题现象 当我们在一个 ajax 回调中执行 window.open 方法时,新页面会被浏览器拦截. 原因 在 Chrome 的安全机制里,非用户直接触发的 window.open 方法,是会被拦截的 ...
- javascript基础扫盲
JavaScript基础扫盲 null和undefined 非十进制的表示方法 强制类型转换 运算 null和undefined null是一个是非来表示一个空对象的,故 typeof 的返回值是ob ...
- tp5 权限设置
============================== <?php/** * Created by PhpStorm. * User: 14155 * Date: 2018/11/10 * ...
- 从0到1发布一个Vue Collapse组件
需求背景 最近在项目中遇到了一个类似Collapse的交互需求,因此到github上找了一圈关于Vue Collapse的相关轮子,但是多少都有些问题.有的是实现问题,例如vue2-collapse, ...
- Java基础学习总结(39)——Log4j 1使用教程
1. 配置文件 Log4J配置文件的基本格式如下: #配置根Logger log4j.rootLogger = [ level ] , appenderName1 , appenderN ...
- POJ - 3126 - Prime
先上题目 Prime Path Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9259 Accepted: 5274 D ...