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

1.3.6.5 2019-09-04 22:58 UTC

This package is not auto-updated.

Last update: 2024-09-12 21:59:48 UTC


README

A PHP Implementation of ZURB's Foundation for Email parser (Inky).

安装

您可以使用 composer 安装此捆绑包

composer require incentfit/inky

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

使用方法和示例

基本使用。

<?php
use IncentFit\Inky\Inky;

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

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

添加标签别名

<?php
use IncentFit\Inky\Inky;

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

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

添加您自己的组件工厂

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

<?php

use IncentFit\Inky\Component\ComponentFactoryInterface;
use IncentFit\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 许可证)。