authanram / html
WORK IN PROGRESS
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:package
Requires
- php: ^8.0
- illuminate/support: ^9.0
- spatie/html-element: ^1.1
Requires (Dev)
- illuminate/view: ^9.0
- nunomaduro/phpinsights: ^2.0
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.20
- pestphp/pest-plugin-mock: ^1.0
This package is auto-updated.
Last update: 2024-10-30 01:54:03 UTC
README
Painless html generation.
Installation
You can install the package via composer.
composer require authanram/html
Basic Usage Example
Here's an example of how it can be used in a very basic way:
use Authanram\Html\Renderer; $qux = [ 'tag' => 'a', 'attributes' => [ 'href' => 'https://github.com/authanram', 'class' => 'text-blue-600', 'data-anchor' => true, ], 'contents' => [ 'authanram at github.com' ], ]; Renderer::renderFromArray($qux);
Renderer::renderFromArray($qux);
will return the following string
:
<a href="https://github.com/authanram" class="text-blue-600" data-anchor> authanram at github.com </a>
Nesting
use Authanram\Html\Renderer; $qux = [ 'tag' => 'p', 'contents' => [ [ 'tag' => 'a', 'attributes' => [ 'class' => 'text-blue-600', 'href' => 'https://github.com/authanram', ], 'contents' => [ [ 'tag' => 'span', 'class' => 'semibold', 'contents' => [ ['authanram at github.com'], ] ], ], ], ], ]; Renderer::renderFromArray($qux);
Renderer::renderFromArray($qux);
will return the following string
:
<p> <a class="text-blue-600" href="https://github.com/authanram"> <span class="semibold"> authanram at github.com </span> </a> </p>
Class Based Usage
As you can see here,
we can achieve the same result using the static method Authanram\Html\Element::make()
:
use Authanram\Html\Element; Element::make( 'a', [ 'href' => 'https://gitub.com', 'class' => 'text-blue-600', ], ['authanram at github.com'], )->render();
Abbreviation Based Usage
...
use Authanram\Html\Element; Element::parse('a.text-blue-600[href=https://gitub.com]') ->render();
Credits
License
The MIT License (MIT). Please see License File for more information.