gourmet / assetic
Assetic for CakePHP 3
0.2.3
2014-08-15 20:41 UTC
Requires
- composer/installers: *
- kriswallsmith/assetic: ~1.1.2
Suggests
- phpunit/phpunit: Allows automated tests to be run without system-wide install.
This package is auto-updated.
Last update: 2024-08-28 00:45:23 UTC
README
这是一个不稳定的仓库,应被视为alpha版本。
更新:现在@mark_story发布了markstory/asset_compress,我已经停止积极开发这个插件。
安装
composer require gourmet/assetic:*
或将此软件包添加到项目的composer.json
"require": {
"gourmet/assetic": "*"
}
用法
AsseticHelper
方法与它们的HtmlHelper
相似,但添加了一些选项。
方法包括
- css($path, $options)
- image($path, $options)
- script(_$url, $options)
添加的$options
键包括
- debug: boolean 默认为应用的配置
debug
值。 - output: string Assetic创建的资产的名称。
- filters: array|string 要使用的过滤器。默认为资产类型的配置过滤器(css,image,js)。
传递给css()
的$path
和传递给script
的$url
可以是字符串或关联数组(请参阅以下示例)。
示例
echo $this->Assetic->css('cake.generic', ['debug' => false, 'filters' => 'cssmin']); echo $this->Assetic->css(['cake.generic' => 'cssmin'], ['debug' => false]); echo $this->Assetic->css('cake.generic');
上述所有示例将产生相同的结果,包括cake.generic.css
的压缩版本。对于最后一个示例,假设Assetic.cssFilters
配置中的值至少包含cssmin
键。
$this->Assetic->css('cake.generic', ['filters' => 'cssmin,?uglify']);
在上面的示例中,在调试模式下,只运行cssmin
过滤器。