gulch / assets

用于收集某些类型的资源(js、css)并将其一次性写入文档的包。

1.1.2 2021-01-31 16:13 UTC

This package is auto-updated.

Last update: 2024-09-11 09:18:15 UTC


README

Coverage Status Scrutinizer Code Quality

gulch/Assets

用于收集某些类型的资源(js、css)并将其一次性写入文档的PHP包。

特别感谢:Funtime 团队。

安装

您需要已安装Composer

composer require gulch/assets

如何使用

use gulch\Assets\Asset;
use gulch\Assets\Renderer\BodyCssRenderer;

$bodyCss = new Asset(new BodyCssRenderer);
$bodyCss->add('asset1.css')->add('asset2.css');
// ...
$bodyCss->add('asset3.css');

// ... and in your html template just write
$bodyCss->write();

结果

<link href="asset1.css" rel="stylesheet" type="text/css" property="stylesheet">
<link href="asset2.css" rel="stylesheet" type="text/css" property="stylesheet">
<link href="asset3.css" rel="stylesheet" type="text/css" property="stylesheet">