wecodepixels/premailer-bundle
最新稳定版本:v0.1.0
Composer 安装命令:
composer require wecodepixels/premailer-bundle
包简介
Symfony bundle for Premailer
README 文档
README
This is a Symfony2 bundle for the Premailer project that uses the Premailer CLI (command line interface).
Prerequisites
You will have to install the Premailer gem as per the official instructions. At the time of writing, the following snippet works properly on a Ubuntu 12.04 LTS installation:
sudo apt-get install ruby-dev sudo gem install premailer nokogiri
Installation
Download the bundle
If you are using Composer as your package manager, you can simply use:
composer require wecodepixels/premailer-bundle:dev-master
Or if you prefer to manually edit your composer.json file:
{
"require": {
"wecodepixels/premailer-bundle": "dev-master"
}
}
and then run composer update wecodepixels/premailer-bundle.
Enable the bundle
Add the bundle inside your AppKernel.php file:
<?php // app/AppKernel.php registerBundles() { $bundles = array( // ... new WeCodePixels\PremailerBundle\WeCodePixelsPremailerBundle(), ); }
Required configuration
You will have to specify the Premailer binary inside your config.yml file (or config_dev.yml, config_prod.yml, etc.). Again, here is an example that works properly on a Ubuntu 12.04 LTS installation:
we_code_pixels_premailer: bin: /usr/bin/premailer
As a tip, you can locate your premailer binary by executing where premailer inside your console.
Usage
Here is a simple example:
$html = '<h1>My HTML which contains one or more style tags</h1>'; $premailer = $this->container->get('we_code_pixels_premailer.premailer'); $premailer->setRemoveClasses(true); $htmlWithInlinedCss = $premailer->execute($html);
There are a few more setters available that are directly linked to the Premailer CLI options:
- setMode
- setBaseUrl
- setQueryString
- setCss
- setRemoveClasses
- setRemoveScripts
- setLineLength
- setEntities
- setIoExceptions
统计信息
- 总下载量: 15.34k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-05-10