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

Overview

Laravel Blade Emerald

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:
  • 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.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 , This component can be used like as an alias. The component support one prop named make which accept the abbreviation

🏷️ Generate static nested markup

div.card-body#box" />">
<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

div.alert.alert-success[role=alert]"> Success ! give it a click if you like. ">
<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
.card-body.text-danger" />">
<x-your-component wrap=".card.bg-dark.pt-2 > .card-body.text-danger" />
produced html

Laravel... The PHP Framework for Web Artisans

">
<div class="card bg-dark pt-2">
    <div class="card-body text-danger">
        
        <p>Laravel... The PHP Framework for Web Artisansp>
        
    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, ...) {
                                        πŸ‘†
    }
    ...
.card-body.text-danger" /> πŸ‘†">
<x-your-component markup=".card.bg-dark.pt-2 > .card-body.text-danger" />
                   πŸ‘†

🧰 Useful Examples

Bootstrap grid
div.row > div.col-md-6">

Hello world!

">
<x-markup make="div.container > div.row > div.col-md-6">
    <p>Hello world!p>
x-markup>
Breadcrumb
ol.breadcrumb"> ">
<x-markup make="nav[aria-label=breadcrumb]>ol.breadcrumb">
    <li class="breadcrumb-item"><a href="#">Homea>li>
    <li class="breadcrumb-item active" aria-current="page">Libraryli>
x-markup>
Bootstrap card with links
Active Link Disabled

With supporting text below as a natural lead-in to additional content.

">
<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=#]">Activex-markup>
        <x-markup make="li.nav-item>a.nav-link[href=#]">Linkx-markup>
        <x-markup make="li.nav-item>a.nav-link.disabled[href=# tabindex=-1 aria-disabled=true]">Disabledx-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
div.mb-3"> ">
<x-markup make="div.form-group>div.mb-3">
    <label for="email" class="form-label">Email addresslabel>
    <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.

You might also like...
Laravel blade directives and php helpers for serverside rendered content, based on browser window size WITHOUT css. Requires Livewire and AlpineJS.

Laravel Livewire Window Size and Breakpoints Laravel blade directives and php helpers for server side rendered content, based on browser window size W

Laravel blade directives and php helpers for serverside rendered content, based on browser window size WITHOUT css

Laravel Window Size and Breakpoints Laravel blade directives and php helpers for server side rendered content, based on browser window size WITHOUT cs

Useful blade components and functionality for most Laravel projects.

laravel-base Note: Package is still in early stages of development, so functionality is subject to change. LaravelBase is a package I've created to pr

Laravel Livewire (TALL-stack) form generator with realtime validation, file uploads, array fields, blade form input components and more.
Laravel Livewire (TALL-stack) form generator with realtime validation, file uploads, array fields, blade form input components and more.

TALL-stack form generator Laravel Livewire, Tailwind forms with auto-generated views. Support Contributions Features This is not an admin panel genera

A package that uses blade templates to control how markdown is converted to HTML inside Laravel, as well as providing support for markdown files to Laravel views.
A package that uses blade templates to control how markdown is converted to HTML inside Laravel, as well as providing support for markdown files to Laravel views.

Install Install via composer. $ composer require olliecodes/laravel-etched-blade Once installed you'll want to publish the config. $ php artisan vendo

Use Laravel's Blade templating engine outside of Laravel.

Use Laravel's Blade templating engine outside of Laravel. This package provides a standalone version of Laravel's Blade templating engine for use outs

Source code behind the Laracasts Larabit: Creating and Using Custom Blade Directives

This is the source code behind the Laracasts Larabit: Creating and Using Custom Blade Directives, and features all of the files and code available in that video.

Custom Blade components to add sortable/drag-and-drop HTML elements in your apps.
Custom Blade components to add sortable/drag-and-drop HTML elements in your apps.

Laravel Blade Sortable Demo Repo Installation You can install the package via composer: composer require asantibanez/laravel-blade-sortable After the

A package to easily make use of Iconic icons in your Laravel Blade views.
A package to easily make use of Iconic icons in your Laravel Blade views.

Blade Iconic A package to easily make use of Iconic icons in your Laravel Blade views. For a full list of available icons see the SVG directory. Iconi

Releases(v1.1.0)
Owner
Aqua
Aqua
Emmet for Sublime Text

This plugin is deprecated and no longer maintained, please use new version. Emmet for Sublime Text Official Emmet plugin for Sublime Text. How to inst

Sergey Chikuyonok 5.3k Jan 5, 2023
This package allows you to render livewire components like a blade component, giving it attributes, slots etc

X-livewire This package allows you to render livewire components like a blade component, giving it attributes, slots etc. Assuming you wanted to creat

null 7 Nov 15, 2022
Blade UI Kit is a set of renderless components to utilise in your Laravel Blade views

Blade UI Kit is a set of renderless components to utilise in your Laravel Blade views. In all essence, it's a collection of useful utilities, connecting the dots between different parts of the TALL stack. It was made for Blade, Laravel's powerful templating engine.

Blade UI Kit 1.2k Jan 5, 2023
Blade Snip allows you to use parts of a blade template multiple times. Basically partials, but inline.

Blade Snip Blade Snip allows you to use parts of a blade template multiple times. Basically partials, but inline: <div class="products"> @snip('pr

Jack Sleight 18 Dec 4, 2022
Eloquent Befriended brings social media-like features like following, blocking and filtering content based on following or blocked models.

Laravel Befriended Eloquent Befriended brings social media-like features like following, blocking and filtering content based on following or blocked

Renoki Co. 720 Jan 3, 2023
Boilerplate code for protecting a form with proof of work. Uses javascript in the browser to generate the hashcash and PHP on the server to generate the puzzle and validate the proof of work.

Boilerplate code for protecting a form with proof of work. Uses javascript in the browser to generate the hashcash and PHP on the server to generate the puzzle and validate the proof of work.

Jameson Lopp 28 Dec 19, 2022
Livewire component that brings Spotlight/Alfred-like functionality to your Laravel application.

About LivewireUI Spotlight LivewireUI Spotlight is a Livewire component that provides Spotlight/Alfred-like functionality to your Laravel application.

Livewire UI 792 Jan 3, 2023
Livewire component that brings Spotlight/Alfred-like functionality to your Laravel application.

About Wire Elements Spotlight Wire Elements Spotlight is a Livewire component that provides Spotlight/Alfred-like functionality to your Laravel applic

Wire Elements 790 Dec 27, 2022
A package to generate YouTube-like IDs for Eloquent models

Laravel Hashids This package provides a trait that will generate hashids when saving any Eloquent model. Hashids Hashids is a small package to generat

Ξ›Π³i 25 Aug 31, 2022
Generate trends for your models. Easily generate charts or reports.

Laravel Trend Generate trends for your models. Easily generate charts or reports. Support us Like our work? You can support us by purchasing one of ou

Flowframe 139 Dec 27, 2022