dust学习
来源:互联网 发布:华策数据科技有限公司 编辑:程序博客网 时间:2024/06/06 18:04
学习链接:https://github.com/linkedin/dustjs/wiki/Dust-Tutorial
测试链接:http://www.dustjs.com/test/test.html
2.数组遍历
3.json对象(数组)
5.父子作用域
6.兄弟作用域(如果A中有type,会覆盖掉B中type)
7. ?(true)和^(false)和:else使用
8.{@select key="xxx"} + @eq, @ne, @lt, @lte, @gt, @gte, @default
11.{@if condition}
测试链接:http://www.dustjs.com/test/test.html
1.变量解析
{name:'zhang'} <div>{name}</div>>>>>> <div></div>
2.数组遍历
['jack','bob','tom'] <div>{.} </div>>>>> <div>jack bob tom </div>
3.json对象(数组)
{friends:[ {name:'tom'}, {name:'jack'}, {name:'jone'} ] }{#friends} <div>{name} - {$idx}-{$len}</div>{/friends}>>>><div>tom - 0 - 3</div><div>jack - 1 - 3</div><div>jone - 2 - 3</div>
4.获取数组长度
{friends:[ {name:'tom'}, {name:'jack'}, {name:'jone'} ] }{@size key=friends/}>>>>3
5.父子作用域
{A:{ name:'A', B:{ name:'B' } }}{#A.B} B的scope:{name}----A的scope:{A.name}{/A.B}>>>>B的scope:B ---- A的scope:A
6.兄弟作用域(如果A中有type,会覆盖掉B中type)
{A:{name:'A'},B:{type:'TB'}}{#A:B} A的name:{name},B的type:{type}{/A}>>>>A的name:A,B的type:TB
7. ?(true)和^(false)和:else使用
{?A} 这里A为true {:else} 这里A为false{/A}>>>>{^A} 这里A为false{:else} 这里A为true{/A}
8.{@select key="xxx"} + @eq, @ne, @lt, @lte, @gt, @gte, @default
{@select key=foo} {@any}Congratulations! You got: {/any} //任何一个满足就会展示any中内容 {@eq value="1"}First Place{/eq} {@eq value="2"}Second Place{/eq} {@eq value="3"}Third Place{/eq} {@none}Better luck next time!{/none} //所有都不满足就会展示none中内容{/select}
9.{@math}
{@math key="16" method="add" operand="4"/} - Result will be 20{@math key="16.5" method="floor"/} - Result will be 16{@math key="16.5" method="ceil"/} - Result will be 17{@math key="-8" method="abs"/} - Result will be 8{@math key="{$idx}" method="mod" operand="2"/} - Return 0 or 1 according to $idx value
{@math key="13" method="add" operand="12"} {@gt value=123} 13 + 12 > 123 {/gt} {@none} Math is fun {/none}{/math}
11.{@if condition}
//测试后,发现@if不起作用。
12.{@sep},忽略数组中中后一项的处理
foo:[{name:'A'},{name:'B'},{name:'C'}]{#foo} {name}{@sep},{/sep}{/foo}>>>>A,B,C
阅读全文
0 0
- dust学习
- dust学习地址
- JEWEL AND DUST
- 后端渲染神器!Dust
- 大鱼吃小鱼游戏-dust.js
- dust的csdn博客开张啦
- Eat my dust 不是我的对手
- Dust-Me selectors 清理你的CSS
- dust or any other sort of external damage. But
- How to control your dust collection with an Arduino (it's easy)
- 学习
- 学习
- 学习
- 学习
- 学习
- 学习
- 学习
- 学习
- 浅谈Link Cut Tree
- git的简单操作
- shell实践——数据库流复制
- Linux下zookeeper的安装与启动
- vue中添加mp3音频文件
- dust学习
- 网站数据库连接_带端口
- Spring Web MVC4
- Adapter内的onItemClick监听器四个arg参数
- 第六场选拔 Problem E: Subarray GCD 水
- git工作流
- 命令汇总
- 修改Spring Boot的运行端口号
- mysql分区功能详细介绍,以及实例