frogbob/inky-php

PHP实现ZURB的Foundation for Email解析器 - 基于thampe/inky

0.0.2 2019-11-08 23:26 UTC

This package is auto-updated.

Last update: 2024-09-09 09:56:30 UTC


README

InkyPHP

PHP实现ZURB的Foundation for Email解析器 - 基于thampe/inky

本包将ZURB的模板语言'Inky'编译成HTML版本,以构建响应式电子邮件模板。

它基于thampe/inky,但遗憾的是已被放弃。

文档

安装

安装包

通过执行以下命令将包添加到您的composer.json中。

composer require frogbob/inky-php

使用示例

基本使用

<?php
use Frogbob\InkyPHP\InkyPHP;

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

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

添加标签别名

<?php
use Frogbob\InkyPHP\InkyPHP;

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

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

添加您自己的组件工厂

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

<?php

use Frogbob\InkyPHP\Component\ComponentFactoryInterface;
use Frogbob\InkyPHP\InkyPHP;
use PHPHtmlParser\Dom\HtmlNode;

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

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

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

许可证

请参阅LICENSE文件以获取许可信息(它是MIT许可证)。