我可以在 xml 电子邮件模板中使用条件分支吗

发布于 2024-09-27 02:33:11 字数 402 浏览 1 评论 0原文

我想要通用的电子邮件模板。目前,我有多个电子邮件模板,其中主题和正文的某些部分已更改。我想将它们与一些条件分支组合在一起,例如,

<email>
   <sub>
      if(condition)
           sub1
      else
           sub2
    </sub>
    <body>
        some text
        if(condition)
             text...
        else
             text...

        body continued...
    </body>
</email>

我可以以任何方式执行此操作吗?

I want to have generalised email templates. Currently I have multiple email templates with some part of the subject and body being changed. I would like to club them together with some conditional branching like,

<email>
   <sub>
      if(condition)
           sub1
      else
           sub2
    </sub>
    <body>
        some text
        if(condition)
             text...
        else
             text...

        body continued...
    </body>
</email>

Can I do this in any way?

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

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

发布评论

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

评论(1

小伙你站住 2024-10-04 02:33:11

对于此任务,最好使用模板引擎。存在纯文本模板引擎(例如 Apache Velocity),您也可以使用它们来生成 XML。还有专门的 XML 模板引擎,例如 XSLT(几乎每个编程环境都有不同的实现)或 Genshi (具有特殊的 XML 模式)。

请查看维基百科模板引擎页面以获取比较表。

For this task it is a good idea to use a template engine. There exist template engines for plain text (like Apache Velocity) which you can use for generating XML too. There are also specialized template engines for XML, like XSLT (with various implementions for nearly every programming environment) or Genshi (with a special XML mode).

Look at the Wikipedia template engine page for a comparison table.

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