doT学习(二)之用法集合
Advanced templating: illustrates defines and includes. Include external snippet defined in a variable:
{{#def.externalsnippet}} Load external template from a file:
{{#def.loadfile('/snippet.txt')}} Load external template from a file and cache in a variable:
{{#def['snippet.txt'] || (def['snippet.txt'] = def.loadfile('/snippet.txt'))}} Use cached file again:
{{#def['snippet.txt']}} Here is a def block that will be used later. This snippet can be referenced from external templates too:
{{##def.snippet1:
Some snippet that will be included {{#def.a}} later {{=it.f1}}
#}} First use of snippet1:
{{#def.snippet1}} Second use of snippet1:
{{#def.snippet1}} Include snippet1 if true:
{{# true && def.snippet1 }} Runtime and Compile time evaluation used together:
{{= it.f3 + {{#def.a + def.b}} }} Include xyz or insert 'not found':
{{#def.xyz || 'not found'}} Set xyz to and exclude result from output:
{{##def.xyz=#}} is identical to {{#(def.xyz=) && ""}} Compare xyz to , show 'xyz is not 1' if false:
{{#def.xyz === || 'xyz is not 1'}} {{ if ({{#!def.abc}}) { }}
{{#def.abc}} is falsy
{{ } }} {{ if ({{#def.xyz === }}) { }}
if(true) block
{{ } }} {{##def.fntest = function() {
return "Function test worked!";
}
#}} {{#def.fntest()}} Conditionals:
{{? !it.altEmail }}
<p>
second email: {{= it.altEmail }}
</p>
{{?? true }}
else case worked
{{?}} Array iterators
{{~ it.farray :p }}
<h1>{{=p.farray}}<h1>
{{~ p.farray :value:i }}
<h2>{{=i}}: {{=value}}</h2>
{{~ value :w }}
<h3>{{=w}}</h3>
{{~}}
{{~}}
{{~}} {{~ ["apple", "banana", "orange"] :k}}
{{=k}}
{{~}} {{~ (function(){ return [,,]})() :k}}
{{=k}}
{{~}} {{ function children(it) { }} {{?it.Nodes.length}}
<ul>
{{~ it.Nodes :p}}
<li>
{{=p.title}}
{{children(p);}}
</li>
{{~}}
</ul>
{{?}} {{ } }} {{ children( {Nodes:[ {title:"1.1", Nodes:[ {title:"1.1.1", Nodes:[]}, {title:"1.1.2", Nodes:[]}] }, { title:"1.2", Nodes:[]}, { title:"1.3", Nodes:[]}], title:"" } ); }} {{##def.block:param:
<div>{{=param}}</div>
#}} {{##def.block1:param:
<div>{{=param.a}}</div>
#}} {{#(def.block:'text' || '') + def.block:}} {{#def.block:it.f3 || ''}} {{#def.block:"lala tralala" || ''}} {{#def.block1:{a:, b:} || ''}} {{##def.testFunctionWithParam = function(str) {
return "My name is: " + str;
}
#}} {{##def.mytestparam: {{=it.name}} #}}
{{#def.testFunctionWithParam(def.mytestparam)}} {{#def.testFunctionWithParam("\{\{=it.name\}\}")}} {{##def.testParamDef:myparam:
My name is: {{=myparam}}
#}} {{#def.testParamDef:it.name}} The end
doT学习(二)之用法集合的更多相关文章
- hibernate学习二 基本用法
一 映射文件User.hbm.xml 定义了持久化类实例是如何存储和加载的,这个文件定义了持久化类和表的映射. 根据映射文件,Hibernate可以生成足够的信息以产生所有的SQL语句,也就是类的实 ...
- python学习博客地址集合。。。
python学习博客地址集合... 老师讲课博客目录 http://www.bootcdn.cn/bootstrap/ bootstrap cdn在线地址 http://www.cnblogs. ...
- 大数据技术之_16_Scala学习_08_数据结构(下)-集合操作+模式匹配
第十一章 数据结构(下)-集合操作11.1 集合元素的映射-map11.1.1 map 映射函数的操作11.1.2 高阶函数基本使用案例1+案例211.1.3 使用 map 映射函数来解决11.1.4 ...
- 学习javascript数据结构(三)——集合
前言 总括: 本文讲解了数据结构中的[集合]概念,并使用javascript实现了集合. 原文博客地址:学习javascript数据结构(三)--集合 知乎专栏&&简书专题:前端进击者 ...
- Object C学习笔记22-#define 用法
上一篇讲到了typedef 关键字的使用,可以参考文章 Object C 学习笔记--typedef用法 .而在c中还有另外一个很重要的关键字#define. 一. #define 简介 在C中利用预 ...
- DjangoRestFramework学习二之序列化组件、视图组件 serializer modelserializer
DjangoRestFramework学习二之序列化组件.视图组件 本节目录 一 序列化组件 二 视图组件 三 xxx 四 xxx 五 xxx 六 xxx 七 xxx 八 xxx 一 序列化组 ...
- Python操作redis学习系列之(集合)set,redis set详解 (六)
# -*- coding: utf-8 -*- import redis r = redis.Redis(host=") 1. Sadd 命令将一个或多个成员元素加入到集合中,已经存在于集合 ...
- 学习笔记 07 --- JUC集合
学习笔记 07 --- JUC集合 在讲JUC集合之前我们先总结一下Java的集合框架,主要包含Collection集合和Map类.Collection集合又能够划分为LIst和Set. 1. Lis ...
- Redis学习系列五Set(集合)
一.简介 Redis中的Set(集合)相当于C#中的HashSet,它内部的键值对时无序的.唯一的.用过Dictionary的都知道,Dictionary都知道,里面的每个键值对肯定是唯一的,因为键不 ...
- day 90 DjangoRestFramework学习二之序列化组件
DjangoRestFramework学习二之序列化组件 本节目录 一 序列化组件 二 xxx 三 xxx 四 xxx 五 xxx 六 xxx 七 xxx 八 xxx 一 序列化组件 首先按照 ...
随机推荐
- JavaWeb_(SSH论坛)_四、页面显示
基于SSH框架的小型论坛项目 一.项目入门 传送门 二.框架整合 传送门 三.用户模块 传送门 四.页面显示 传送门 五.帖子模块 传送门 六.点赞模块 传送门 七.辅助模块 传送门 帖子表与回复表 ...
- sqli-labs(39)
0X01 这关和38关一样 ?id= and =1 正确 ?id=1 and 1=2 错误 不需要闭合 构造语法 0X02 ?id=;insert into users values(,"z ...
- What’s up with the Graph Laplacian
What's up with the Graph Laplacian? 来源 作者:Jeremy Kun blog: Math ∩ Programming 在数学上图和与图关联的某些矩阵的代数性质有很 ...
- Android Handler 内存泄漏问题
1. 问题先看以下代码: 第一种写法: public class MainActivity extends AppCompatActivity { ... ... ... private class ...
- 【攻克RabbitMQ】常见问题
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明.本文链接:https://blog.csdn.net/zlt995768025/article/ ...
- [学习笔记] CNN与RNN方法结合
CNN与RNN的结合 问题 前几天学习了RNN的推导以及代码,那么问题来了,能不能把CNN和RNN结合起来,我们通过CNN提取的特征,能不能也将其看成一个序列呢?答案是可以的. 但是我觉得一般直接提取 ...
- 五一 DAY 6
五一 DAY 6 TypeName 类型名 VariableName 变量名 Part 1 数据结构 函数库:# include < utility > Pair 定义一个变量,它 ...
- Application 使用分析
一. Application 分析 1. Application 简介 (1) Application 概念 Application 概念 : Application 属于组件范畴; -- 本质 : ...
- 使用ViewPager实现广告自动轮播的效果
package com.loaderman.viewpgerlunbodemo; import android.os.Bundle; import android.os.Handler; import ...
- centos7.5搭建svn
1.安装svnyum install subversion 2.查看安装位置rpm -ql subversion 3.创建svn版本库目录mkdir -p /var/svn/svnrepos 4.创建 ...