generalmedia / twigemailrenderbundle
Rendering email using Twig
This package's canonical repository appears to be gone and the package has been frozen as a result. Email us for help if needed.
Package info
github.com/GeneralMediaCH/TwigEmailRenderBundle
Type:symfony-bundle
pkg:composer/generalmedia/twigemailrenderbundle
Requires
- swiftmailer/swiftmailer: ~5.0|~6.0
- twig/twig: ~1.0|~2.0
Requires (Dev)
- phpunit/phpunit: ^5.7|^6.1
- symfony/phpunit-bridge: ^2.7|^3.0|^4.0
- symfony/symfony: ~2.8|~3.0
- symfony/twig-bundle: ~2.3|~3.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
TwigEmailRenderBundle renders twig templates as emails. You can define multiple block in your template, each block will be added to your email as a different part (object,body,text).
Changelog
3.0.1
- Changes dependencies for twig v2
3.0.0
- Drop support for PHP 5.5 + Add test for PHP 7.0 + 7.1
2.0.1
- Fix hasBlock detection with parent templates.
2.0.0 DO NOT USE
- Support global variables
- Add option 'strict_variables'
Installation
Install the latest version with
$ composer require generalmedia/twigemailrenderbundle
You can also add this to your composer.json and run composer update
"require": { "generalmedia/twigemailrenderbundle" : "~3.0.0" },
Add this to you AppKernel:
new Generalmedia\TwigEmailRenderBundle\TwigEmailRenderBundle(),
Note: Use ~2.0 for php 5.5.
Usage
Render email like twig views:
$msg = $this->get("generalmedia_email_render_twig")->getMessage("MyTemplate.email.twig"); $msg->setTo("...@..."); $this->get("mailer")->send($msg);
Your template is rendered with 3 blocks:
- Block subject: Your email subject
- Block text : Your email text
- Block html: Your email html.
Subject is mandatory, and you must define at least one of theses blocks: text, html.
Configuration
All theses block names can be configured as follow:
twig_email_render: blocks: subject: 'email_subject' text: 'email_text' html: 'email_html'
Author
Laurent Constantin for Generalmedia SA.
Contact info@generalmedia.ch if needed.
License
TwigEmailRenderBundle is licensed under the MIT License - see the LICENSE file for details