florian-koerner/chimpdrill

此包已被 放弃 并不再维护。未建议替代包。

简单的 Mailchimp / Mandrill 合并标签解析器

v1.2.0 2014-11-18 12:05 UTC

This package is auto-updated.

Last update: 2020-12-18 16:57:54 UTC


README

Build Status Scrutinizer Code Quality Coverage Status SensioLabsInsight

Mailchimp 和 Mandrill 合并标签语法的解析器。支持 占位符过滤器条件

安装

使用 composer 下载 ChimpDrill

php composer.phar require florian-koerner/chimpdrill:dev-master

或者将以下代码添加到您的 composer.json

{
    "require": {
        "florian-koerner/chimpdrill": "dev-master"
    }
}

使用方法

$chimpdrill = new \FlorianKoerner\ChimpDrill\ChimpDrill($message, $placeholder);

var_dump((string) $chimpdrill);
// or
var_dump($chimpdrill->getParsed());

示例

消息

<h1>Hi *|NAME|*</h1>

<p>
    *|IF:CUSTOMER|*
        We want your money!
    *|ELSE:|*
        We wish you all the best.
    *|END:IF|*
</p>

<p>
    *|IF:INVOICE_COUNT == 0|*
        All invoices payed. You are the best!
    *|ELSEIF:INVOICE_COUNT <= 5|*
        Oops... You have open invoices.
    *|ELSE:|*
        Are you kidding?
    *|END:IF|*
</p>

<ul>
    <li>The current year is: *|DATE:Y|*</li>
    <li>Current weather: *|UPPER:WEATHER|*</li>
    <li>Best movie ever: *|TITLE:MOVIE|*</li>
</ul>

参数

array(
    'NAME' => 'John Doe',
    'CUSTOMER' => true,
    'INVOICE_COUNT' => 18,
    'WEATHER' => 'rainy',
    'MOVIE' => 'The last song'
)

结果

<h1>Hi John Doe</h1>

<p>
    We want your money!
</p>

<p>
    Are you kidding?
</p>

<ul>
    <li>The current year is: 2014</li>
    <li>Current weather: RAINY</li>
    <li>Best movie ever: The Last Song</li>
</ul>

我爱开源

I Love Open Source