花粉解决方案 - 资产组件 - 管理CSS样式、JS脚本等

v1.0.10 2022-10-14 00:00 UTC

This package is auto-updated.

Last update: 2024-09-13 13:33:56 UTC


README

Latest Stable Version MIT Licensed PHP Supported Versions

花粉解决方案 Asset 组件提供管理Web应用程序中资产的工具。

允许添加内联CSS样式,添加内联JS脚本或将PHP变量传递到JS全局变量,以便在您的脚本中访问它们。

安装

composer require pollen-solutions/asset

基本用法

use Pollen\Asset\AssetManager;

$asset = new AssetManager();

// Add inline CSS
$asset->addInlineCss(
    'body {
        background-color:AliceBlue;
    }'
);

// Add inline JS
$asset->addInlineJs(
    'console.log("value1");
     console.log("value2");
     console.log("value3");'
);

// Add global JS var
// -- app namespaced
$asset->addGlobalJsVar('test1', 'test-value1');

// -- in footer
$asset->addGlobalJsVar('test2', 'test-value2', true);

// -- in footer and without namespace
$asset->addGlobalJsVar('test3', 'test-value3', true, null);

注册资产

@todo

排入队列资产

@todo

缓存和压缩

即将推出