freemarker 基础和派生 ftl;s
我想问自由标记语言是否支持面向对象。 如果我有
Base.ftl
{
@Generalmacro
{
@derived
}
}
Derived1.ftl include Base.ftl
{
@Generalmacro
@derived
}
Derived2.ftl include Base.ftl
{
@Generalmacro
@derived
}
选项可以从每个派生ftl需要定义的抽象方法之类的base.ftl中调用派生1和派生2。
I want to ask if object oriented is supported in free marker language.
If I have
Base.ftl
{
@Generalmacro
{
@derived
}
}
Derived1.ftl include Base.ftl
{
@Generalmacro
@derived
}
Derived2.ftl include Base.ftl
{
@Generalmacro
@derived
}
Is there option to call derived1 and derived2 from the base.ftl like abstract method that each derived ftl need to define.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
虽然 FreeMarker 不支持 OOP 或任何类型的模板/宏继承,但您想要实现的目标(如果我理解得很好)是可能的。您可以在@generalmacro 中调用尚未定义的@categories 宏,然后在另一个文件中定义@categories,在其中#include 定义然后调用@generalmacro 的文件。
While FreeMarker doesn't support OOP or any kind of template/macro inheritance, what you want to achieve (if I understand it well) is possible. You can have a call to the yet undefined @derived macro in @generalmacro, and then define @derived in another file, where you #include the file that defines and then calls @generalmacro.