mustache模板引擎
2015-06-13 22:34
363 查看
Logic-less templates.github:http://mustache.github.com/ 文档:http://mustache.github.com/mustache.5.html http://mustache.github.ioJava
版 Mustache SVN 源码http://jmustache.googlecode.com/svnmustache 类似 freemark和valicity
模板引擎,不过mustache 更轻量级,支持语言: Ruby, JavaScript, Python,Erlang, node.js, PHP, Perl, Perl6, Objective-C, Java, C#/.NET, Android, C++, Go, Lua,ooc, ActionScript, ColdFusion, Scala, Clojure,Fantom, CoffeeScript, D, Haskell, XQuery,ASP, Io, Dart, Haxe, Delphi, Racket, Rust,OCaml, Swift,
and for Bashmustache 支持功能比较弱,不过我们可以建立在mustache 之上进行扩展实现。mustache的特点就是很语法很简单,主要语法如下{{ name }} 打印变量,默认是escape过的,如果不要escape,用3个分隔符 {{{ name }}},或者用 {{ &name }},这个和分隔符无关
{{#person}}…{{/person}} 区块,4种方式person是真假值,决定是否输出
person 是list of array,会循环展开 for x in person:section.render('xxx)
person 是匿名函数/object, 区块包裹的html 会作为参数传递进去
person 是dict,直接打印 dict[key]{{^person}}…{{/person},反向区块
{{!name }} 注释
{{> box }} 载入子模块Template:
版 Mustache SVN 源码http://jmustache.googlecode.com/svnmustache 类似 freemark和valicity
模板引擎,不过mustache 更轻量级,支持语言: Ruby, JavaScript, Python,Erlang, node.js, PHP, Perl, Perl6, Objective-C, Java, C#/.NET, Android, C++, Go, Lua,ooc, ActionScript, ColdFusion, Scala, Clojure,Fantom, CoffeeScript, D, Haskell, XQuery,ASP, Io, Dart, Haxe, Delphi, Racket, Rust,OCaml, Swift,
and for Bashmustache 支持功能比较弱,不过我们可以建立在mustache 之上进行扩展实现。mustache的特点就是很语法很简单,主要语法如下{{ name }} 打印变量,默认是escape过的,如果不要escape,用3个分隔符 {{{ name }}},或者用 {{ &name }},这个和分隔符无关
{{#person}}…{{/person}} 区块,4种方式person是真假值,决定是否输出
person 是list of array,会循环展开 for x in person:section.render('xxx)
person 是匿名函数/object, 区块包裹的html 会作为参数传递进去
person 是dict,直接打印 dict[key]{{^person}}…{{/person},反向区块
{{!name }} 注释
{{> box }} 载入子模块Template:
{{#person?}} Hi {{name}}! {{/person?}}Hash:
{ "person?": { "name": "Jon" } }Output:
Hi Jon!Template:
{{#repo}} <b>{{name}}</b> JS-USE:{{#first}}++{{/first}} JAVA-USE: first:{{-first}} last:{{-last}} index:{{-index}} {{/repo}} {{^repo}} No repos :( {{/repo}}Hash:
{ "repo": [] }Output:
No repos :(
相关文章推荐
- AC自动机 学习链接
- 哈希(6) - 判断数组中是否存在重复元素且距离在K之内
- 【转】Netflix工程总监眼中的分类算法:深度学习优先级最低
- replace into导致mysql自增列导致主键重复问题分析
- leetcode之Construct Binary Tree from Preorder and Inorder Traversal
- C#打开/保存文件,获取路径
- xcode armv6 armv7 armv7s arm64指令集
- xcode armv6 armv7 armv7s arm64指令集
- hdu5269 数据结构Trie
- android 动态添加组件出现的一些问题
- 数据库--模糊查询
- Delphi XE8如何同Eclipse使用相同的Android SDK?
- 详解Java解析XML的四种方法
- mysql开启事件
- Delphi XE8如何同Eclipse使用相同的Android SDK?
- Delphi XE8如何同Eclipse使用相同的Android SDK?
- 阅读第10、11、12章
- 水平拆分优缺点
- 自说自话
- 获取元素的通用函数