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. java 发送http请求

    参考别人的 package test; import java.io.BufferedReader; import java.io.IOException; import java.io.InputS ...

  2. React-Router ---withRouter

    import React from 'react' import { withRouter } from 'react-router' const Hello = (props) => { re ...

  3. idea中git回滚到指定分支

    1.git - > show history,选中回滚的指定版本,右击copy revision number 粘出版本号 2.git -> reset hard 出险新页面之后,选中ha ...

  4. C#第五节课

    switch语句 using System;using System.Collections.Generic;using System.Linq;using System.Text;using Sys ...

  5. 类型信息、异常、I/O流(day11)

    二十三 运行时的类型信息 typeid运算符 #include <typeinfo> typeid(类型/对象) )返回typeinfo的对象,用于描述类型信息. )在typeinfo类中 ...

  6. Qt5.11+opencv3.4的配置安装

    系统:Windows 10 64位 前期准备: 1.CMake下载安装 下载地址:https://cmake.org/download/ 选择msi安装文件,按照提示一步一步按照就好 可以参考:htt ...

  7. 2019-04-12 SQL 主键约束

    create table dbo.AssetPool( ID bigint not null, poolname nvarchar(50)not null, constraint pk_AssetPo ...

  8. 渗透实战(周三):Ettercap·ARP毒化&MITM中间人攻击

    今天,我们来讲解如何对小型Wi-Fi局域网发动网络攻击

  9. 【Educational Codeforces Round 53 (Rated for Div. 2) C】Vasya and Robot

    [链接] 我是链接,点我呀:) [题意] [题解] 如果|x|+|y|>n 显然.从(0,0)根本就没法到(x,y) 但|x|+|y|<=n还不一定就能到达(x,y) 注意到,你每走一步路 ...

  10. (29)Spring boot 文件上传(多文件上传)【从零开始学Spring Boot】

    文件上传主要分以下几个步骤: (1)新建maven java project: (2)在pom.xml加入相应依赖: (3)新建一个表单页面(这里使用thymleaf); (4)编写controlle ...