结束标签

可以在结束标签中忽略user_def_dir_exp 也就是说可以写</@>来代替</@anything>

循环变量

<@myRepeatMacro count=4>

  SomeThing...

</@>

<@myRepeatMacro count=4 ;x>

  ${x}.SomeThing...

</@>

<@myRepeatMacro count=4 ;x,last>  //自定义指令创建的循环变量和分号之后指定的循环变量数量需要不匹配  last可以不写  x也可以不写

  ${x}.Something...<#if last>This was the last!</#if>

</@>

位置参数传递:  目前仅仅支持宏定义

macro,nested,return指令

没有参数的宏

<#macro test>

  Test text

</#macro>

<@test/>  --> Test text

有参数的宏:

<#macro test foo bar baaz>

  Test test,and the params:${foo},${bar},${baaz}

</#macro>

<@test foo="a" bar="b" baaz=5*5-2/>

-->  Test text,and the params:a,b,23

一个复杂的宏

<#macro list title items>

  <p>${title?cap_first}:

  <ul>

    <#list>

      <li>${x?cap_first}

    </#list>

  </ul>

</#macro>

<@list item=["mouse","elephant","python"] title="Animals"/>

-->  <p>Animals:

  <ul>

    <li>Mouse

    <li>Elephant

    <li>Python

  </ul>

function return 指令

<#function name param1 param2 ... paramN>

  ...

  <#return returnVlalue>

  ...

</#function>

例子:
<#function avg x y >
  <#return (x+y)/2>
</#function>
${avg(10,20)}
-->15

freemarker3的更多相关文章

随机推荐

  1. eclipse debug 错误 之 processWorkerExit

    eclipe 在debug模式下,有时候老是跳转到 ThreadPoolExecutor 之 processWorkerExit方法,很是让人恼火,是 因为在 java.util.concurrent ...

  2. spring spel表达式语言

    一.通过bean的id对bean进行引用 1.对其他bean的引用 <property name="dept" value="#{dept}"/> ...

  3. 【LeetCode】113. Path Sum II

    Path Sum II Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals ...

  4. 那些最好的轮子 - PHP篇

    转载于:http://avnpc.com/pages/best-wheels-for-php 在关于不要重复造轮子的二三事一文中,交代了一些背景和想法.本篇则完全是一些干货,列举一些我用过或者即将会用 ...

  5. 连接oracle时报错:ORA-28001: the password has expired

    调试Web项目的时候出现异常: java.sql.SQLException: ORA-28001: the password has expired 网上查了一下,是Oracle11g密码过期的原因 ...

  6. 稳固而窒息 jquery attr 和 Prop的区别

    通常在获取或者设置checked,selected,readonly,disabled等的时候使用prop效果更好 attr是通过setAtrribute和getAttribute来设置的,使用的是D ...

  7. unity5,UI Button too small on device than in Game View解决办法

    假设测试设备为iphone5(横屏).下面说明如何使真机上ui显示效果与Game View中一致. 1,首先Game View左上角屏幕规格选 iPhone 5 Wide (16:9),如图: 2,在 ...

  8. Informix 配置选项

    下表列出了用于改善数据库性能的附加选项.如果选择在 onconfig 配置文件中进行更改,则需要重新启动 Informix 通用服务器.可以在 Informix 服务器处于联机或脱机状态时编辑 onc ...

  9. github提交一个空目录

    github默认不上传空目录,有的时候需要空目录来保持程序的结构. 二个小问题. 1.始终保持空目录,即时里面有文件,也全部忽略掉. 建立一个.gitignore文件放到空目录内. mkdir emp ...

  10. Windows 2003 IIS 不支持ASP问题的解决方法

    有时候我们在配置iis的时候,为了安全关闭了asp的支持,下面我们来介绍下让iis支持asp的一些注意事项特别注意:当我们在没有配置好iis的时候,不要安装补丁了,组件之类的东西,先把网站弄开通了,再 ...