1. Advanced templating: illustrates defines and includes.
  2.  
  3. Include external snippet defined in a variable:
  4. {{#def.externalsnippet}}
  5.  
  6. Load external template from a file:
  7. {{#def.loadfile('/snippet.txt')}}
  8.  
  9. Load external template from a file and cache in a variable:
  10. {{#def['snippet.txt'] || (def['snippet.txt'] = def.loadfile('/snippet.txt'))}}
  11.  
  12. Use cached file again:
  13. {{#def['snippet.txt']}}
  14.  
  15. Here is a def block that will be used later. This snippet can be referenced from external templates too:
  16. {{##def.snippet1:
  17. Some snippet that will be included {{#def.a}} later {{=it.f1}}
  18. #}}
  19.  
  20. First use of snippet1:
  21. {{#def.snippet1}}
  22.  
  23. Second use of snippet1:
  24. {{#def.snippet1}}
  25.  
  26. Include snippet1 if true:
  27. {{# true && def.snippet1 }}
  28.  
  29. Runtime and Compile time evaluation used together:
  30. {{= it.f3 + {{#def.a + def.b}} }}
  31.  
  32. Include xyz or insert 'not found':
  33. {{#def.xyz || 'not found'}}
  34.  
  35. Set xyz to and exclude result from output:
  36. {{##def.xyz=#}} is identical to {{#(def.xyz=) && ""}}
  37.  
  38. Compare xyz to , show 'xyz is not 1' if false:
  39. {{#def.xyz === || 'xyz is not 1'}}
  40.  
  41. {{ if ({{#!def.abc}}) { }}
  42. {{#def.abc}} is falsy
  43. {{ } }}
  44.  
  45. {{ if ({{#def.xyz === }}) { }}
  46. if(true) block
  47. {{ } }}
  48.  
  49. {{##def.fntest = function() {
  50. return "Function test worked!";
  51. }
  52. #}}
  53.  
  54. {{#def.fntest()}}
  55.  
  56. Conditionals:
  57. {{? !it.altEmail }}
  58. <p>
  59. second email: {{= it.altEmail }}
  60. </p>
  61. {{?? true }}
  62. else case worked
  63. {{?}}
  64.  
  65. Array iterators
  66. {{~ it.farray :p }}
  67. <h1>{{=p.farray}}<h1>
  68. {{~ p.farray :value:i }}
  69. <h2>{{=i}}: {{=value}}</h2>
  70. {{~ value :w }}
  71. <h3>{{=w}}</h3>
  72. {{~}}
  73. {{~}}
  74. {{~}}
  75.  
  76. {{~ ["apple", "banana", "orange"] :k}}
  77. {{=k}}
  78. {{~}}
  79.  
  80. {{~ (function(){ return [,,]})() :k}}
  81. {{=k}}
  82. {{~}}
  83.  
  84. {{ function children(it) { }}
  85.  
  86. {{?it.Nodes.length}}
  87. <ul>
  88. {{~ it.Nodes :p}}
  89. <li>
  90. {{=p.title}}
  91. {{children(p);}}
  92. </li>
  93. {{~}}
  94. </ul>
  95. {{?}}
  96.  
  97. {{ } }}
  98.  
  99. {{ 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:"" } ); }}
  100.  
  101. {{##def.block:param:
  102. <div>{{=param}}</div>
  103. #}}
  104.  
  105. {{##def.block1:param:
  106. <div>{{=param.a}}</div>
  107. #}}
  108.  
  109. {{#(def.block:'text' || '') + def.block:}}
  110.  
  111. {{#def.block:it.f3 || ''}}
  112.  
  113. {{#def.block:"lala tralala" || ''}}
  114.  
  115. {{#def.block1:{a:, b:} || ''}}
  116.  
  117. {{##def.testFunctionWithParam = function(str) {
  118. return "My name is: " + str;
  119. }
  120. #}}
  121.  
  122. {{##def.mytestparam: {{=it.name}} #}}
  123. {{#def.testFunctionWithParam(def.mytestparam)}}
  124.  
  125. {{#def.testFunctionWithParam("\{\{=it.name\}\}")}}
  126.  
  127. {{##def.testParamDef:myparam:
  128. My name is: {{=myparam}}
  129. #}}
  130.  
  131. {{#def.testParamDef:it.name}}
  132.  
  133. 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. Jmeter -- 同步定时器

    作用: 模拟并发. 设置一个阀值(请求数量),当请求数达到这个阀值时,允许请求同时发出.例如:想测试一座桥的并发(忽略载重等其他因素,只考虑通过),那么并发的请求就是类似于多少辆车可同时通过桥,而车辆 ...

  2. STS(Spring tool suite)集成配置jdk,maven和Tomcat

    STS是spring官网的一个集成开发工具,最近在学springboot,所以用了. 在本文中将介绍如下内容: 搭建开发的 JDK(1.8) 环境. 配置 Maven 环境. 配置 Tomcat 环境 ...

  3. 使用oracle删除表中重复记录

    (1)使用用rowid方法 查询重复数据:select * from person a where rowid !=(select max(rowid) from person b where a.c ...

  4. bootstrap 学习笔记(部分)

    这个课程中的boostrap是3.0+版本的.(2.0与3.0有区别) bootstrap中的JS是依赖于jquery的,所以需要事先引用jquery(1.9.0版本以上). <!DOCTYPE ...

  5. spark 笔记 4:Apache Hadoop YARN: Yet Another Resource Negotiator

    spark支持YARN做资源调度器,所以YARN的原理还是应该知道的:http://www.socc2013.org/home/program/a5-vavilapalli.pdf    但总体来说, ...

  6. The 5 types of programmers

    from: http://stevenbenner.com/2010/07/the-5-types-of-programmers/ps: 评论也很精彩 In my code journeys and ...

  7. java 深入HashMap

    HashMap也是我们使用非常多的Collection,它是基于哈希表的 Map 接口的实现,以key-value的形式存在.在HashMap中,key-value总是会当做一个整体来处理,系统会根据 ...

  8. [SQL]数据库常用语句

    1.使用旧表创建新表 SELECT * INTO CC FROM AA ; (适用于版本SQL SERVER)

  9. Python之异常处理-Exception

    在写python程序时, 不要害怕报错, 也不要怕自己的英语不够好, 不要看到一有红色的字就心里发怂. 其实报的错也是有套路可寻滴~识别了异常的种类, 才能对症下药. 常见异常: Exception ...

  10. Linux_基础指令

    目录 目录 前言 cd和pwd ls cat du mkdir touch rm cp mv which whereis find ln head和tail wc tar vim useradd 添加 ...