我对所有电子邮件都使用主模板。我希望这个主模板使用从具体模板传递的 ID 字段:
some-email.html
#{set 'emailId'}1{/set}
#{extends 'app/views/Mails/mail-main.html' /}
...
mail-main.html(这是主模板)
// Here, I would like to use the emailId parameter inside another template.
// Specifically, a link I'm rendering
<a href="@@{Foo.bar(emailId)}`>Link text</a>
但是,如果我理解正确的话,这不是 set
和 get
模板的工作原理 - 它们只允许我将对象嵌入到模板中的模板文本中使用 get
,而不是将其传递给其他模板。
有没有一种简单的方法可以实现我想要的功能?
最佳答案
您可以在 mail-main.html 中编写以下内容:
<a href="@@Foo.bar(get('emailId'))">Link text</a>
关于java - 如何将参数传递给我正在扩展的模板,并在模板内使用它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9350888/