简体   繁体   English

Mailjet 模板语言(TWIG、PUG 语法)-如何在内联样式道具中使用模板变量?

[英]Mailjet templating language(TWIG, PUG syntax) - how to use template variable within inline style prop?

I'm trying to customize my e-mail templates using the Mailjet Passport tool.我正在尝试使用 Mailjet Passport 工具自定义我的电子邮件模板。 The HTML code generated by Passport Drag and Drop tool, supports templating language that is similiar to Twig. Passport 拖放工具生成的 HTML 代码,支持类似于 Twig 的模板语言。

What I need to achieve is to put variable for inline style property like on the code example below:我需要实现的是为内联样式属性放置变量,如下面的代码示例所示:

  <span
    style="color: {{var: PARTNER_COLOR:"#d2d2d2"}};" // it does not work
   >
    Lorem ipsum {{var:PARTNER_NAME:"Default Partner"}}.mywebstite.de <!-- this work as expected -->
 </span>

Interpolating the {{var:VARIABLE_NAME}} within inner HTML content or for src attribute works as expected, but I'm not able to figure out how to use them with the style attribute.在内部 HTML 内容或src属性中插入{{var:VARIABLE_NAME}}可以按预期工作,但我无法弄清楚如何将它们与style属性一起使用。 Maybe there is some other solution for dynamically changing color values for css color , background properties in my e-mail templates?也许还有其他一些解决方案可以动态更改我的电子邮件模板中 css colorbackground属性的颜色值?

Docs are very poor to be honest, but here is the reference: Maijlet Templating Language Docs说实话,文档很差,但这里是参考: Maijlet Templating Language Docs

After couple of days I have finally found and answer.几天后,我终于找到并回答了。 For anyone looking for this in the future there can't be any space sign before the curly braces and var declaration like in the example below:对于将来要查找此内容的任何人,在花括号和 var 声明之前不能有任何空格符号,如下例所示:

BAD:坏的:

<span
    style="color: {{var: PARTNER_COLOR:"#d2d2d2"}};" // it does not work
   >
    Lorem ipsum {{var:PARTNER_NAME:"Default Partner"}}.mywebstite.de <!-- this work as expected -->
</span>

GOOD:好的:

 <span
    style="color:{{var:PARTNER_COLOR:"#d2d2d2"}};" // THIS WORKS!
   >
    Lorem ipsum {{var:PARTNER_NAME:"Default Partner"}}.mywebstite.de <!-- this work as expected -->
 </span>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM