如何声明要在几个 ajax 视图中使用的 freemarker 宏/函数?

发布于 2025-01-02 07:22:10 字数 107 浏览 2 评论 0原文

我目前有一个<#macro format_phone 电话>在我的代码中,一些不同的页面使用它。我怎样才能使这个功能对多个页面可用? IE。全球。目前它是复制粘贴的,打破了 DRY 原则。

I currently have a <#macro format_phone phone> within my code, and a few different pages use it. How could I make this function be available to many pages? ie. globally. Currently it's copied and pasted, breaking the DRY principle.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

嗼ふ静 2025-01-09 07:22:10

您可以将其放入 macros.ftl 文件中,<#import "macros.ftl" as m>,然后 <@m.format_phone phone> ;

You can put it in a macros.ftl file, <#import "macros.ftl" as m>, and then <@m.format_phone phone>

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