aqua/blade-emerald 问题修复 & 功能扩展

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

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

aqua/blade-emerald

Composer 安装命令:

composer require aqua/blade-emerald

包简介

Emmet like Abbreviation to generate and wrap Laravel Blade Component with markup

README 文档

README

Emmet like Abbreviation to generate and wrap Laravel Blade Component with markup

Latest Version on Packagist Total Downloads GitHub Tests Action Status Open Issues License

example static markup example blade component

🌈 Features

  • Generate HTML in a Blade file via package provided component: <x-markup make="div.col>span#alert">
  • Emmet style syntax to produce nested markup
  • Wrap around any content / other component with markup
  • Make any Blade Component accept abbreviation to wrap itself with markup ( doesn't work for Anonymous Components )

🛸 Compatibility

Package Version Laravel version PHP version Compatible
^1.2 10.* 8.1 - 8.2 🟢
^1.0 9.* 8.0 - 8.1 🟢
^1.0 8.* 7.3 - 8.0 🟢
7.* 7.3 - 7.4 🔴

📥 Installation

composer require aqua/blade-emerald

📖 Usage

💡 The package provides a Blade Component <x-emerald-markup />, This component can be used like <x-markup ...> as an alias. The component support one prop named make which accept the abbreviation

🏷️ Generate static nested markup

<x-markup make="div.card[style='color:green;'] > div.card-body#box" />

produced html

<div class="card" style="color:green;">
    <div class="card-body" id="box"></div>
</div>

🏷️ Wrap some content

<x-markup make="div.col>div.alert.alert-success[role=alert]">
    <strong>Success !</strong> give it a click if you like.
</x-markup>
produced html
<div class="col">
    <div class="alert alert-success" role="alert">
        <strong>Success !</strong> give it a click if you like.
    </div>
</div>

🏷️ Accept abbreviation in your Blade Component

this feature doesn't support Anonymous Components

  1. use Aqua\Emerald\Traits\Markup trait in your Component Class
class YourComponent extends Component {
    use Markup;
    ...
  1. the Markup trait assumes the prop name to be wrap, so lets add this as a class property & instantiate
public function __construct(public $wrap) {...} // using php 8.0 constructor property promotion

read more about constructor property promotion

  1. accept abbreviation
<x-your-component wrap=".card.bg-dark.pt-2 > .card-body.text-danger" />
produced html
<div class="card bg-dark pt-2">
    <div class="card-body text-danger">
        <!-- actual content of your-component -->
        <p>Laravel... The PHP Framework for Web Artisans</p>
        <!-- actual content of your-component -->
    </div>
</div>
  1. accept abbreviation using prop of your choise to customize the prop name that receives the abbreviation create a static property $wrapby and set its value to your prop name
class YourComponent extends Component {
    use Markup;

    protected static $wrapby = 'markup'; 👈

    public function __construct(public $markup, ...) {
                                        👆
    }
    ...
<x-your-component markup=".card.bg-dark.pt-2 > .card-body.text-danger" />
                   👆

🧰 Useful Examples

Bootstrap grid
<x-markup make="div.container > div.row > div.col-md-6">
    <p>Hello world!</p>
</x-markup>
Breadcrumb
<x-markup make="nav[aria-label=breadcrumb]>ol.breadcrumb">
    <li class="breadcrumb-item"><a href="#">Home</a></li>
    <li class="breadcrumb-item active" aria-current="page">Library</li>
</x-markup>
Bootstrap card with links
<x-markup make="div.card.text-center">
    <x-markup make="div.card-header>ul.nav.nav-pills.card-header-pills">
        <x-markup make="li.nav-item>a.nav-link.active[href=#]">Active</x-markup>
        <x-markup make="li.nav-item>a.nav-link[href=#]">Link</x-markup>
        <x-markup make="li.nav-item>a.nav-link.disabled[href=# tabindex=-1 aria-disabled=true]">Disabled</x-markup>
    </x-markup>
    <div class="card-body">
        <p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
    </div>
</x-markup>
Bootstrap form-group
<x-markup make="div.form-group>div.mb-3">
    <label for="email" class="form-label">Email address</label>
    <input type="email" class="form-control" id="email" aria-describedby="emailHelp" />

    <x-markup make="div>div.#emailHelp.form-text>span.text-danger.validation-msg" />
</x-markup>
Self closing tag
<x-markup make="img#profile[src=/avatar.jpg width=80]" />
Alpine x-for
<ul x-data="{ colors: [{ id: 1, label: 'Green' }, ...] }">
    <x-markup make="template[x-for=color in colors] [:key=color.id] > li[x-text=color.label]" />
</ul>

equivalent to

<ul x-data="{ colors: ...}">
    <template x-for="color in colors" :key="color.id">
        <li x-text="color.label"></li>
    </template>
</ul>

📚 Abbreviation Guide

checkout spatie/html-element to get more idea.

Syntax Example Description
#id p#foo ID attribute
.class p.foo Class attribute
> div.row>div.col Nesting with child
[style='color:green;'] div[style='color:green;'] Single attribute
[title=Hello world][data-foo=bar] Multiple attributes

📅 Changelog

Please see CHANGELOG for more information on what has changed recently.

🏆 Credits

This package is actually a wrapper around spatie/html-element, all the hard work has been done by Team Spatie so they deserve all the credits. All I did is make it work with Laravel Blade Components.

🎫 License

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

aqua/blade-emerald 适用场景与选型建议

aqua/blade-emerald 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 63 次下载、GitHub Stars 达 31, 最近一次更新时间为 2021 年 10 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「html」 「laravel」 「Blade component」 「Blade HTML Markup Generate」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 aqua/blade-emerald 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 aqua/blade-emerald 我们能提供哪些服务?
定制开发 / 二次开发

基于 aqua/blade-emerald 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 31
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-10-02