freemarker 基础和派生 ftl;s

发布于 2024-12-22 00:02:36 字数 271 浏览 2 评论 0原文

我想问自由标记语言是否支持面向对象。 如果我有

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

七色彩虹 2024-12-29 00:02:36

虽然 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文