An open API service indexing awesome lists of open source software.

https://github.com/aqquaa/blade-emerald

Emmet like Abbreviation to generate and wrap Laravel Blade Component with markup
https://github.com/aqquaa/blade-emerald

emmet-abbreviations laravel laravel-blade laravel-blade-component markup

Last synced: 7 months ago
JSON representation

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

Awesome Lists containing this project

README

          

# Laravel Blade Emerald
> [Emmet](http://emmet.io/) like Abbreviation to generate and wrap [Laravel](https://laravel.com/) [Blade Component](https://laravel.com/docs/master/blade#components) with markup

[![Latest Version on Packagist](https://badgen.net/packagist/v/aqua/blade-emerald?label=latest&color=cyan)](https://packagist.org/packages/aqua/blade-emerald)
[![Total Downloads](https://badgen.net/packagist/dt/aqua/blade-emerald)](https://packagist.org/packages/aqua/blade-emerald)
[![GitHub Tests Action Status](https://github.com/aqquaa/blade-emerald/actions/workflows/test.yaml/badge.svg)](https://github.com/aqquaa/blade-emerald/actions/workflows/test.yaml)
[![Open Issues](https://badgen.net/github/open-issues/aqquaa/blade-emerald?color=red)](https://github.com/aqquaa/blade-emerald/issues?q=is%3Aopen+is%3Aissue)
[![License](https://badgen.net/github/license/aqquaa/blade-emerald)](https://github.com/aqquaa/blade-emerald/blob/master/LICENSE.md)


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.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

```shell
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

```html

```
> produced html
```html




```

#### 🏷️ Wrap some content
```html

Success ! give it a click if you like.

```

produced html

```html



Success ! give it a click if you like.


```

#### 🏷️ Accept abbreviation in your Blade Component

> this feature doesn't support *Anonymous Components*

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

3. accept abbreviation
```html

```

produced html

```html




Laravel... The PHP Framework for Web Artisans





```

4. 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

```php
class YourComponent extends Component {
use Markup;

protected static $wrapby = 'markup'; 👈

public function __construct(public $markup, ...) {
👆
}
...
```

```html

👆
```

## 🧰 Useful Examples

Bootstrap grid

```html

Hello world!

```

Breadcrumb

```html


```

Bootstrap card with links

```html


Active
Link
Disabled


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


```

Bootstrap form-group

```html

Email address

```

Self closing tag

```html

```

Alpine x-for

```html




```
> equivalent to
```html





```

## 📚 Abbreviation Guide
checkout [spatie/html-element](https://github.com/spatie/html-element#examples) 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](CHANGELOG.md) for more information on what has changed recently.

## 🏆 Credits
This package is actually a wrapper around [spatie/html-element](https://github.com/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.

- [![Follow](https://badgen.net/twitter/follow/srvrksh?icon=twitter&label=Sourav%20R)](https://twitter.com/srvrksh)
- [All Contributors](../../contributors)

## 🎫 License

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.