Mandrill模板中的条件内容 [英] Conditional content in Mandrill template

查看:175
本文介绍了Mandrill模板中的条件内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将字典键(键值对)移交给服务,该服务又利用api通过Mandrill发送电子邮件。

I am handing over dictionary keys (key value pair) to a service which in turn utilizes the api to send the email via Mandrill.

现在,如果我的密钥为空,那么我不希望它包含在电子邮件中。就像在下面的场景中一样,我只希望显示链接文本,如果我的键有一些值。

Now, if my key is blank then i dont want it to be included in the email. Like in the following scenario, i only want the link text to display if my key has some value.

< a href = | UPDATE_PROFILE | target =_ blank>更改订阅首选项< / a>

<a href="|UPDATE_PROFILE|" target="_blank" >change subscription preferences</a>

我怎么能写出一些类似的东西,甚至可能呢?

How can i write it some thing like or even is this possible?

if *|UPDATE_PROFILE|* IS NOT EMPTY
BEGIN
<a href="*|UPDATE_PROFILE|*" target="_blank">change subscription preferences</a> 
END


推荐答案

我在这里找到了答案:
http:/ /help.mandrill.com/entries/28427818-Can-I-use-dynamic-or-conditional-merge-tags-

I have found the answer here: http://help.mandrill.com/entries/28427818-Can-I-use-dynamic-or-conditional-merge-tags-

这是信息来自页面:

条件合并标签支持传统的IF,ELSE和ELSEIF逻辑以及IFNOT负面条件。

Conditional merge tags support traditional IF, ELSE, and ELSEIF logic as well as IFNOT negative conditions.

仅当条件评估为真时才使用IF条件显示内容。

Use IF conditions to display content only when the condition evaluates as true.

*|IF:MERGE|*
content to display if a value for MERGE is provided
*|END:IF|*


*|IF:MERGE=x|*
    content to display if the value for MERGE is x
*|END:IF|*

使用时像 | IF:MERGE = x | 这样的条件,并且没有提供MERGE的值,条件将评估为false。

When using a condition like |IF:MERGE=x|, and no value for MERGE is provided, the condition will evaluate as false.

使用IF和ELS E条件为真时显示内容的条件,但条件评估为假时显示替代内容。

Use IF and ELSE conditions to display content when a condition is true, but alternate content when the condition evaluates as false.

*|IF:MERGE|*
    content to display
*|ELSE:|*
    alternative content
*|END:IF|*

ELSEIF条件

使用ELSEIF显示几种可能的选项之一。只会显示第一个条件后评估为真的内容 - 其他条件将被跳过。

Use ELSEIF to display one of several possible options. Only the content following the first condition evaluated as true will be displayed—other conditions will be skipped.

*|IF:MERGE=x|*
    <p>content to display if the value for MERGE is x</p>
*|ELSEIF:MERGE=y|*
    <p>content to display if the value for MERGE is not x, but is y</p>
*|ELSEIF:MERGE=z|*
    <p>content to display if the value for MERGE is not x or y, but is z</p>
*|ELSE:|*
    <p>alternate content to display if the value for MERGE is not x, y, or z</p>
*|END:IF|*

嵌套条件

*|IF:MERGE1=x|*
    *|IF:MERGE2=y|*
          <div mc:edit="main"> 
                <p>content to display if both conditions are true</p>
           </div>
    *|END:IF|*
*|END:IF|*

负面条件

*|IF:MERGE!=x|*
    content to display if the value for MERGE is not x
*|ELSE:|*
    content to display if the value for MERGE is x
*|END:IF|*


*|IFNOT:MERGE|*
    content to display if MERGE is not provided
*|ELSE:|*
    content to display if MERGE is provided
*|END:IF|*

在mycase中使用

*|IF:UPDATE_PROFILE|*
                    <p>IMPORTANT NOTE: *|LAYOUTYEAR|*  
                        available for review at: http://www.somesite.org/SomePage.</p>
                *|ELSE:|*
                    <p>
                        <a href="http://www.somesite.org/SomePage" target="_blank">Click here</a>
                        to view the detailed specs.
                    </p>
                *|END:IF|*

这篇关于Mandrill模板中的条件内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆