honda/pushed-resources 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

honda/pushed-resources

Composer 安装命令:

composer require honda/pushed-resources

包简介

Add styles or scripts on the fly

README 文档

README

Tests Formats Version Total Downloads License

Installation

You can install the package via composer:

composer require honda/pushed-resources

Usage

Pushing resources

Using Blade

<x-assets-script async src="script.js"/>

<x-assets-raw-script>
    console.log('Hello there!')
</x-assets-raw-script>

<x-assets-style href=" style.css"/>

<x-assets-raw-style>
    * { background: rebeccapurple }
</x-assets-raw-style>

<x-assets-blade>
    @livewireStyles
    @livewireScripts
</x-assets-blade>

Using PHP

use Honda\PushedResources\Resources\Script;
use Illuminate\View\ComponentAttributeBag;

Script::create()
    ->value('something.js')
    ->attributes(['a' => 'b']) // or
    ->attributes(new ComponentAttributeBag(['a' => 'b']));

Retrieving resources

Using Blade

<x-assets-render type="*"/>
<x-assets-render type="script"/>
<x-assets-render type="script,raw-script"/>
<x-assets-render type="style,raw-style"/>
<x-assets-render type="style,raw-style"/>

Using PHP

use Honda\PushedResources\Resources\Script;
use Illuminate\View\ComponentAttributeBag;

Script::create()
    ->value('something.js')
    ->attributes(['a' => 'b']) // or
    ->attributes(new ComponentAttributeBag(['a' => 'b']));

You can also use Style, Script, RawScript, RawStyle, Blade in the same namespace

Custom Types

A good use case for that is livewire assets, you may not want to those on a page where you are not using Livewire. You could do something like this:

// app/View/Resources/BladeScript or wherever you think it makes sense.
class BladeScript extends \Honda\PushedResources\Resources\Blade {
    public function getTag() : string{
        return 'blade-script';
    }
}
// app/View/Components/BladeScript.php
class BladeScript extends \Honda\PushedResources\Components\Blade {}
// in a page with livewire
<x-blade-script>
    <livewire-scripts/>
</x-blade-script>

// at the bottom of
<body> in your layout file
<x-assets-render type="blade-script"/>

Testing

composer test

Octane

This package is compatible with Laravel Octane.

Credits

License

The MIT License (MIT). Please see License File for more information. .

统计信息

  • 总下载量: 1.37k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-03-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固