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学习(二)之用法集合的更多相关文章

  1. hibernate学习二 基本用法

    一  映射文件User.hbm.xml 定义了持久化类实例是如何存储和加载的,这个文件定义了持久化类和表的映射. 根据映射文件,Hibernate可以生成足够的信息以产生所有的SQL语句,也就是类的实 ...

  2. python学习博客地址集合。。。

    python学习博客地址集合...   老师讲课博客目录 http://www.bootcdn.cn/bootstrap/  bootstrap cdn在线地址 http://www.cnblogs. ...

  3. 大数据技术之_16_Scala学习_08_数据结构(下)-集合操作+模式匹配

    第十一章 数据结构(下)-集合操作11.1 集合元素的映射-map11.1.1 map 映射函数的操作11.1.2 高阶函数基本使用案例1+案例211.1.3 使用 map 映射函数来解决11.1.4 ...

  4. 学习javascript数据结构(三)——集合

    前言 总括: 本文讲解了数据结构中的[集合]概念,并使用javascript实现了集合. 原文博客地址:学习javascript数据结构(三)--集合 知乎专栏&&简书专题:前端进击者 ...

  5. Object C学习笔记22-#define 用法

    上一篇讲到了typedef 关键字的使用,可以参考文章 Object C 学习笔记--typedef用法 .而在c中还有另外一个很重要的关键字#define. 一. #define 简介 在C中利用预 ...

  6. DjangoRestFramework学习二之序列化组件、视图组件 serializer modelserializer

      DjangoRestFramework学习二之序列化组件.视图组件   本节目录 一 序列化组件 二 视图组件 三 xxx 四 xxx 五 xxx 六 xxx 七 xxx 八 xxx 一 序列化组 ...

  7. Python操作redis学习系列之(集合)set,redis set详解 (六)

    # -*- coding: utf-8 -*- import redis r = redis.Redis(host=") 1. Sadd 命令将一个或多个成员元素加入到集合中,已经存在于集合 ...

  8. 学习笔记 07 --- JUC集合

    学习笔记 07 --- JUC集合 在讲JUC集合之前我们先总结一下Java的集合框架,主要包含Collection集合和Map类.Collection集合又能够划分为LIst和Set. 1. Lis ...

  9. Redis学习系列五Set(集合)

    一.简介 Redis中的Set(集合)相当于C#中的HashSet,它内部的键值对时无序的.唯一的.用过Dictionary的都知道,Dictionary都知道,里面的每个键值对肯定是唯一的,因为键不 ...

  10. day 90 DjangoRestFramework学习二之序列化组件

      DjangoRestFramework学习二之序列化组件   本节目录 一 序列化组件 二 xxx 三 xxx 四 xxx 五 xxx 六 xxx 七 xxx 八 xxx 一 序列化组件 首先按照 ...

随机推荐

  1. LibreOJ NOI Round #2 Day 1

    LibreOJ NOI Round #2 Day 1 T1: 别被定义弄晕了 反着做,A->1/A+B 取倒数没法做,所以变成a/b,维护2*2的矩阵 区间?不用线段树,不用倍增 存在逆矩阵,直 ...

  2. PriorityQueue源码阅读

    最小堆:优先级权重越小 离顶点越近 案例 实现一个top max n publish static int[] topN(int[] nums, int l){ int[] result = new ...

  3. TCP定时器 之 FIN_WAIT_2定时器

    当TCP主动关闭一端调用了close()来执行连接的完全关闭时会执行以下流程,本端发送FIN给对端,对端回复ACK,本端进入FIN_WAIT_2状态,此时只有对端发送了FIN,本端才会进入TIME_W ...

  4. 第七周课程总结&实验报告五

    实验四 类的继承 实验目的 理解抽象类与接口的使用: 了解包的作用,掌握包的设计方法. 实验要求 掌握使用抽象类的方法. 掌握使用系统接口的技术和创建自定义接口的方法. 了解 Java 系统包的结构. ...

  5. scrum例会报告+燃尽图02

    此作业要求参见:https://edu.cnblogs.com/campus/nenu/2019fall/homework/9955 一.小组情况 组长:贺敬文组员:彭思雨 王志文 位军营 徐丽君队名 ...

  6. JAVA-Runnable、Callable、FutureTask

    通常,创建线程的执行单元有两种,一种是直接继承 Thread,另外一种就是实现 Runnable 接口. 但这两种都有一个问题就是无法有返回值,且子线程在执行过程中无法抛出异常.想线程有返回值,可以使 ...

  7. Upload 上传

    通过点击或者拖拽上传文件 点击上传 通过 slot 你可以传入自定义的上传按钮类型和文字提示.可通过设置limit和on-exceed来限制上传文件的个数和定义超出限制时的行为.可通过设置before ...

  8. css换行用省略号代替

    css换行用省略号代替,也可以说是长标题的文章可以使用简单的CSS样式实现省略号控制显示. 一般的文字截断(适用于内联与块): .text-overflow{ display:block;/*内联对象 ...

  9. LeetCode.914-一副牌中的X(X of a Kind in a Deck of Cards)

    这是悦乐书的第352次更新,第377篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第214题(顺位题号是914).在一副牌中,每张牌上都写有一个整数. 当且仅当您可以选择 ...

  10. 微信小程序开发(三)----- 云开发案例

    1.发送请求 2.云函数中发送请求,例子request https://github.com/request/request-promise    创建云函数movielist,右键在终端打开,输入  ...