frogbob/inky-php

PHP Implementation of ZURB's Foundation for Email parser - Based on thampe/inky

0.0.2 2019-11-08 23:26 UTC

This package is auto-updated.

Last update: 2024-12-09 10:37:37 UTC


README

InkyPHP

PHP Implementation of ZURB's Foundation for Email parser - Based on thampe/inky

This package compiles ZURB's template-language 'Inky' to it's html version to build responsive email-templates.

It's based on thampe/inky which unfortunately is abandoned.

Docs

Installation

Install package

Add the package in your composer.json by executing the command.

composer require frogbob/inky-php

Usage and Examples

Basic Usage.

<?php
use Frogbob\InkyPHP\InkyPHP;

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

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

Add Tag-Alias

<?php
use Frogbob\InkyPHP\InkyPHP;

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

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

Add your own component factory

Add your own component factory, to convert custom HTML-Tags.

<?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

See the LICENSE file for license info (it's the MIT license).