peepitkm/laravel-html-css-email-inliner

Laravel HTML & CSS 邮件内联包装器 PHP CssToInlineStyles (https://github.com/tijsverkoyen/CssToInlineStyles)

2.0.0 2016-03-12 10:39 UTC

This package is not auto-updated.

Last update: 2024-09-21 16:38:38 UTC


README

为了让 HTML 邮件工作,您需要将所有 CSS 规则内联以确保在所有地方都能正常工作。在开发代码时这会变得很麻烦,这就是为什么您想要一个可以即时完成的包。

这只是一个 Laravel 包装器,用于 PHP CssToInlineStyles (https://github.com/tijsverkoyen/CssToInlineStyles)

安装

Laravel 5.x

首先,通过 Composer 安装此包。

$ composer require peepitkm/laravel-html-css-email-inliner

在 app.php 中添加 Inliner 作为服务提供者

'providers' => [
	Emil\Inliner\InlinerServiceProvider::class,
]

添加 Inliner 别名

'aliases' => [
	Emil\Inliner\Facades\Laravel\Inliner::class
]

Laravel 4.x

首先,通过 Composer 安装此包。

$ composer require peepitkm/laravel-html-css-email-inliner "1.x-dev"

在 app.php 中添加 Inliner 作为服务提供者

'providers' => [
	'Emil\Inliner\InlinerServiceProvider',
]

添加 Inliner 别名

'aliases' => [
	'Inliner' => 'Emil\Inliner\Facades\Laravel\Inliner'
]

快速示例

禁用/启用内联器

内联器默认启用

Inliner::disable();
Inliner::enable();

检查内联器是否启用/禁用

Inliner::isDisabled();
Inliner::isEnabled();

已知问题

  • 不支持伪选择器
  • 不支持 css-escapes
  • UTF-8 字符集可能无法正确检测。请确保使用以下 meta 标签在 head 中将字符集设置为 UTF-8: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />(注意:使用 <meta charset="UTF-8"> 不起作用!)