📜  twig inky 到 html (1)

📅  最后修改于: 2023-12-03 14:48:03.573000             🧑  作者: Mango

Twig Inky to HTML

Introduction

Twig Inky to HTML is a library that allows developers to use the power of the Twig templating language with the simplicity and flexibility of the Inky email framework. With Twig Inky to HTML, developers can easily create beautiful and responsive email templates in no time.

How to Use

To start using Twig Inky to HTML, follow these steps:

  1. Install the package using composer:
composer require xtremegrids/twig-inky
  1. Create a new Twig environment:
use Twig \ Environment;
use Twig \ Loader \ FilesystemLoader;

$loader = new FilesystemLoader (__DIR__ . '/templates');
$twig = new Environment ($loader);
  1. Load the Inky extension:
use Xtremegrids \ Twig \ InkyExtension;

$twig->addExtension (new InkyExtension ());
  1. Compile your Twig template:
$html = $twig->render ('email.twig', $data);
Features

Twig Inky to HTML comes with a number of features that make it ideal for creating beautiful and responsive email templates. Some of the key features include:

  • Easy integration with existing Twig templates
  • Full support for all Inky elements and components
  • Simple and intuitive syntax for creating responsive frameworks
  • Built-in support for mobile-first design principles
  • Automatic inlining of CSS styles
  • Support for custom CSS stylesheets
  • Full compatibility with modern email clients
Code Snippet

Here's an example of how easy it is to use Twig Inky to HTML:

{% raw %}
{% inky %}
    <container>
        <row>
            <columns>
                <h1>Hello, {{ name }}!</h1>
                <p>This is an example of a responsive email template.</p>
                <button href="{{ url }}">Click Here</button>
            </columns>
        </row>
    </container>
{% endinky %}
{% endraw %}
Conclusion

With Twig Inky to HTML, developers can easily create beautiful and responsive email templates using the power of Twig and the flexibility of Inky. The library is easy to use and comes with a range of features that make it ideal for creating modern and effective email campaigns.