vysokeskoly/to-inline-style-email-bundle
Composer 安装命令:
composer require vysokeskoly/to-inline-style-email-bundle
包简介
A Symfony bundle for using the CssToInlineStyles translator by tijsverkoyen
README 文档
README
ToInlineStyleEmailBundle is a Symfony2 bundle to use the CssToInlineStyles translator by Tijs Verkoyen (see https://github.com/tijsverkoyen/CssToInlineStyles for the repository)
Requirements
ToInlineStyleEmailBundle is only supported on PHP 8.1 and up.
Installation
Please, use the Composer to install this bundle in your Symfony2 app.
The following lines should be added in your composer.json
"require": { "vysokeskoly/to-inline-style-email-bundle": "^3.0" },
Then, register the bundle in your AppKernel by adding the following line:
VysokeSkoly\ToInlineStyleEmailBundle\ToInlineStyleEmailBundle::class => ['all' => true],
Documentation and Examples
The bundle provides a service named css_to_inline_email_converter. Use it in a controller to have a nice shortcut to the converter developed by Tijs Verkoyen. E.g.:
public function indexAction() { $converter = $this->get('css_to_inline_email_converter'); ... }
Get the HTML and the CSS as a string and set this required values to the converter object, e.g.
$converter = $this->get('css_to_inline_email_converter'); $html = ...; // get the HTML here $css = ....; // get the CSS here return $converter->inlineCSS($html, $css);
The retrieval of the HTML and CSS files from its folder it is only up-to you. E.g. in your controller retrieve the content of your CSS as:
file_get_contents($this->container->getParameter('kernel.root_dir').'/../src/Acme/TestBundle/Resources/css/mystyle.css');
Of course, it is supposed that a Symfony user will use a template instead of a static HTML page. Hence, for convenience, the service provides a function capable to render a template. E.g.:
$converter->setHTMLByView( 'AcmeTestBundle:MyController:my_template.html.twig', [ 'param_1' => $val_of_param_1, // ..., 'param_n' => $val_of_param_n ] );
The preceding function must be used in vece of function setHTML().
To use the generateStyledHTML method just use it like:
$converter->setHtml($html); $converter->setCss($css); return $converter->generateStyledHTML();
You can use inline css directly in Twig template:
{% inlinecss '/css/email.css' %}
<div class="foo">
...
</div>
{% endinlinecss %}
Paths relative to bundle are supported as well:
{% inlinecss '@AppBundle/Resources/css/email.css' %}
<div class="foo">
...
</div>
{% endinlinecss %}
Dynamic variable is supported (Use absolute path with variable with asset or directly with full path to file)
{% set path = asset('css/email.css', null, true) %}
{% inlinecss path %}
<div class="foo">
...
</div>
{% endinlinecss %}
Dynamic variable is supported (Use absolute path with variable with asset or directly with full path to file)
{% set path = asset('css/email.css', null, true) %}
{% inlinecss path %}
<div class="foo">
...
</div>
{% endinlinecss %}
Read the docs in the files for further details on the usage of the service.
Contributing
ToInlineStyleEmailBundle is an open source project, under MIT license. Contributions are encouraged. Feel free to contribute to improve this bundle.
About the author of the bundle
ToInlineStyleEmailBundle has been originally developed by Roberto Trunfio. Currently, the bundle is mantained by Luis Cordova via the gushphp organization.
The initial package on packagist robertotru was moved here to gushphp organization with the author consent for maintenance.
vysokeskoly/to-inline-style-email-bundle 适用场景与选型建议
vysokeskoly/to-inline-style-email-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 58.65k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2022 年 07 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「css」 「email」 「bundle」 「inline」 「style」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 vysokeskoly/to-inline-style-email-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vysokeskoly/to-inline-style-email-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 vysokeskoly/to-inline-style-email-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Twig extension to insert css as inline styles with a tag
Caching and compression for Twig assets (JavaScript and CSS).
The bundle for easy using json-rpc api on your project
Bundle Symfony DaplosBundle
Extensible library for building notifications and sending them via different delivery channels.
Email+ extends Kirby's email capabilities by adding support for multiple email services using the same Kirby email API.
统计信息
- 总下载量: 58.65k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-07-11