如何在ftl中使用宏
我对ftl中的宏和函数的实现充满了困惑。 任何人都可以添加一些有用的信息。
and what is the difference between macro and function in ftl
谢谢
I have full of confusion in implementing the macro and functions in ftl.
can any one please add some useful information.
and what is the difference between macro and function in ftl
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
宏和函数之间的区别:宏通常用于生成标记(或其他长文本)以及流程控制和副作用。函数用于计算其他类型的值,包括短的纯文本,并且通常没有副作用。这些反映在宏没有返回值,它们只是直接打印到输出上。另外,宏的输出不会被 #escape 转义。这也是为什么它们看起来与 HTML 标记相似,而
${myFunction()}
则不然。除此之外,你还有什么困惑呢?我假设您已经找到了 FreeMarker 手册。
The difference between macros and functions: macros are for generating markup (or other long text) and for flow-control and side-effects in general. Functions are for calculating other kind of values, including short plain text, and usually has no side-effects. These are reflected by that fact that macros has no return value, they just directly print to the output. Also the output of macros is not escaped by #escape. That's also why they look similar to HTML tags, while
${myFunction()}
doesn't.Other than that, what are you confused about? I assume you have found the FreeMarker Manual.
下面是如何在 FTL 中使用宏的答案:)
Input-smooks.Json:
Smook-config.xml 文件:
定义一次宏并在需要时用作函数
<@PopulateTasks json.accounts.element/>< /code> 这是调用宏的方法
Below is the answer how to use macros in FTL :)
Input-smooks.Json:
Smook-config.xml file:
Define macros once and use as function whenever required
<@PopulateTasks json.accounts.element/>
this is the way to call macros