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

1.3.7 2019-02-21 08:48 UTC

This package is auto-updated.

Last update: 2024-09-21 22:52:41 UTC


README

PHP 实现的 ZURB 的电子邮件解析器 (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 许可证)。