PHP实现ZURB的邮件解析器(Inky)

1.3.6.3 2019-03-31 17:27 UTC

This package is auto-updated.

Last update: 2024-09-29 05:45:35 UTC


README

不会处理问题报告和pull请求。

Inky

PHP实现ZURB的邮件解析器(Inky)(Inky)。

安装

您可以使用composer安装此包

composer require hampe/inky

或直接将包添加到您的composer.json文件中。

用法和示例

基本用法。

<?php
use Hampe\Inky\Inky;

$gridColumns = 12; //optional, default is 12
$additionalComponentFactories = []; //optional
$inky = new Inky($gridColumns, $additionalComponentFactories);

$inky->releaseTheKraken('html...');

添加标签别名

<?php
use Hampe\Inky\Inky;

$inky = new Inky();
$inky->addAlias('test', 'callout')

$inky->releaseTheKraken('<test>123</test>'); //equal to "<callout>123</callout>"

添加自己的组件工厂

添加自己的组件工厂,用于转换自定义HTML标签。

<?php

use Hampe\Inky\Component\ComponentFactoryInterface;
use Hampe\Inky\Inky;
use PHPHtmlParser\Dom\HtmlNode;

class TestComponentFactory implements ComponentFactoryInterface
{
    public function getName()
    {
        return 'test' // name of the html tag.
    }

    public function parse(HtmlNode $element, Inky $inkyInstance)
    {
        // ...
    }
}

$inky = new Inky();
$inky->addComponentFactory(new TestComponentFactory());
$inky->releaseTheKraken('<test></test>');

许可证

有关许可证信息,请参阅LICENSE文件(它是MIT许可证)。