Coder Social home page Coder Social logo

zurbinkbundle's Introduction

GremoZurbInkBundle

Latest stable Downloads total GitHub issues

Warning ⛔ this project is now archived. It's ok to use it for legacy Symfony 2/3 projects, it should work fine. New Symfony project should use twig/cssinliner-extra and twig/inky-extra (see inlining CSS and use inky).

Creating email templates is hard. This Symfony Bundle provides help.

The original bundle thampe/ZurbInkBundle is abandoned. This fork aims to provide a maintained version of the original project. I use this bundle at work, on daily basis, and I respect semantic versioning.

Do you have a good idea and want to contribute? Let's do it! Feel free to open an issue.

Upgrade

  • Last tag supporting Symfony 2 and 3 is 4.0.1. After that, this project only support Symfony 4 and 5.
  • Latest tag of the original project is 2.2.6. You can use this release only changing your Composer requirements.
  • Latest 2.x tag of my fork is 2.3.0 and contains some bug fixes. You can use this release changing your Composer requirements and bundle name in the kernel.

Installation

Install the bundle via Composer:

composer require gremo/zurb-ink-bundle

Then enable the bundle in the config/bundles.php:

<?php
// config/bundles.php

return [
    // ...
    Gremo\ZurbInkBundle\GremoZurbInkBundle::class => ['all' => true],
    // ...
];

Usage

First we need to create a template for our HTML email. You can use Foundation for Emails and Inky or write it from scratch.

Working with Foundation for Emails and Inky

Foundation for Emails is a framework for building HTML responsive emails while Inky is a templating language that converts simple HTML tags into the complex table HTML required for emails.

Extend the base Foundation for Emails layout and override the content block:

{% extends '@GremoZurbInk/foundation-emails/base.html.twig' %}

{% block content %}
    {# Inky markup and plain HTML #}
{% endblock %}

The base layout includes Foundation for Emails CSS (inlined only). Custom styles can be added overriding the stylesheets block (see Adding styles).

From scratch

Not using Foundation for Emails or Inky markup? Extend the base layout and override the body block:

{% extends '@GremoZurbInk/base.html.twig' %}

{% block body %}
    {# Plain HTML #}
{% endblock %}

Custom styles can be added overriding the stylesheets block (see Adding styles).

Adding styles

Email clients typically support only a subset of valid HTML, and don’t have strong support for CSS (especially CSS in the <head> of the HTML email). Yahoo, Outlook, and even Gmail strip CSS that’s included in the <head> of your HTML, so in most cases CSS inlining is necessary.

Stylesheets can be added calling the zurb_ink_add_stylesheet Twig function inside the stylesheets block:

{# ... #}

{% block stylesheets %}
    {{ parent() }}

    {# Custom CSS (inlined only) #}
    {{ zurb_ink_add_stylesheet('css/style.css') }}
{% endblock %}

{# ... #}

By default this will only inline the CSS. Pass a truthy value as second argument to both inline and output the CSS into the <style> tag:

{# ... #}

{% block stylesheets %}
    {{ parent() }}

    <style type="text/css">
        {# Custom CSS (both inlined and outputted) #}
        {{ zurb_ink_add_stylesheet('@AppBundle/Resources/public/css/style.css', true) }}
    </style>
{% endblock %}

{# ... #}

zurbinkbundle's People

Contributors

alcaeus avatar antograssiot avatar davidromani avatar doughayward avatar gremo avatar hracik avatar huebs avatar istvancsabakis avatar sanpii avatar signor-pedro avatar tchapi avatar tgabi333 avatar thampe avatar zo0o0ot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

zurbinkbundle's Issues

zurb_ink_add_stylesheet only looks in src/ and Resources, it should also look in assets folder

As of symfony4 it seems the prefered way to put css files is in the assets folder

however when I try to do

{{ zurb_ink_add_stylesheet('css/email.css') }}

it complains

An exception has been thrown during the rendering of a template ("The file "css/email.css" does not exist (in: /var/www/symfony4/src, /var/www/symfony4/src/Resources).").

Can it be made that it looks also through the assets folder ?

PHP 7.2 makes an error while using Inky

Hi, I've already updated my stack to PHP 7.2 and every time I try to send email which is generated by this bundle I've got:

Uncaught PHP Exception Twig_Error_Runtime:
"An exception has been thrown during the rendering of a template
("Warning: count(): Parameter must be an array or an object that implements Countable")."
at /var/www/vendor/gremo/zurb-ink-bundle/src/Resources/views/FoundationForEmails/2/base.html.twig
 line 44

Any tip what could be wrong?

Package locked at ^2.3 in composer.json

Support for Symfony 5

Hi, is this package still maintained?

I would like to ask if we can expect SF5 support anytime soon, or are you welcoming pull requests?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.