FreeMarker准备在2.4版中加入新的指令#template

FreeMarker准备在2.4版中加入新的指令#template, 用于上下文隔离包含模板. 与原有的#include相对应, #include为上下文内包含(内嵌)模板.

然而, 大家对这一新指令的命名都极不赞同.

首先template是一个名词, 不适合用于包含这样一个动作性指令名.
[quote="Attila Szegedi 回复的邮件"]Sorry for nitpicking, but shouldn't such a directive rather be a verb?
I.e. #load, #render, #execute come to mind. Using a noun (#template) sounds as if you're defining something (see: #macro, #function, etc.).[/quote]

中间引出大量回复, 给出了n多方案, 如:
#subtemplate, #safeinclude, #load, #exec, #render, #do. #process, #merge, #embed

赞同较多的是: #render, #process, #embed
但render(渲染)与图形学上的概念混淆, 表意不清.
process(处理)太过泛化, 这个词感觉什么地方都可用.
embed(嵌入)是比较合理的. 但似乎应该与现有的include指令名换一个才恰当. 因为embed才表示在当前上下文执行, include表示包含内容(在不同上下文执行).
[quote="Daniel Dekany 回复的邮件"]Should I replace all application of #include with #embed in the 2.4 Manual? #include was one of the first few directives introduced (in the Getting Started chapter). I suppose now we should propagate #embed instead. Also I wonder if #include should be deprecated in 2.4.[/quote]

最后结论还没出来, 但对CommonTemplate([url]http://commontemplate.org[/url])的设计很有借鉴意义, 现在CommonTemplate采用inline(内联)表示同上下文包含, include(包含)表示上下文隔离包含, 似乎将inline改成embed会更合理些, 可能会在下一版本进行变更.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值