hnhdigital-os/laravel-html-generator
Laravel Html Generator
Create HTML tags and render them efficiently.
Extends upon Airmanbzh/php-html-generator with some Laravel related integration.
Overview
return HtmlTag::createElement();
// returns an empty HtmlTag Container
return HtmlTag::createElement('a');
// returns an HtmlTag containing a 'a' tag
Why you should use it
- it always generates valid HTML and XHTML code
- it makes templates cleaner
- it's easy to use and fast to execute
Render tags
echo(HtmlTag::createElement('a'));
Simple tags
echo $html->tag('div')
// <div></div>
echo(HtmlTag::createElement('p')->text('some content'));
// <p>some content</p>
Structured tags
echo(HtmlTag::createElement('div')->addElement('a')->text('a text'));
// <div><a>a text</a></div>
$container = HtmlTag::createElement('div');
$container->addElement('p')->text('a text');
$container->addElement('a')->text('a link');
// <div><p>a text</p><a>a link</a></div>
Attributes
Classics attributes (method : 'set')
$tag = $html->tag('a')
->set('href','./sample.php')
->set('id','myID')
->text('my link');
echo( $tag );
// <a href='https://github.com/hnhdigital-os/laravel-html-generator/blob/HEAD/sample.php' id='myID'>my link</a>
ID (method : 'id')
$tag = $html->tag('div')
->id('myID');
echo( $tag );
// <div id='myID'>my link</a>
Class management (method : 'addClass'/'removeClass')
$tag = $html->tag('div')
->addClass('firstClass')
->addClass('secondClass')
->text('my content')
->removeClass('firstClass');
echo( $tag );
// <div class="secondClass">my content</div>
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.
Related Packages
doctrine/dbal
Powerful PHP database abstraction layer (DBAL) with many features for database s...
648,266,899
9,701
laravel/serializable-closure
Laravel Serializable Closure provides an easy and secure way to serialize closur...
429,221,767
607
nunomaduro/collision
Cli error handling for console/command-line PHP applications.
403,217,078
4,664
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 3.2.3 | ^8.0 | ^9.21| | MIT | |
| 3.2.2 | ^8.0 | ^9.21| | MIT | |
| 3.2.1 | ^8.0 | ^9.21| | MIT | |
| 3.2.0 | ^8.0 | ^9.21| | MIT | |
| 3.1.5 | ^8.0 | ^9.21| | MIT | |
| 3.1.4 | ^8.0 | ^9.21| | MIT | |
| 3.1.3 | ^8.0 | ^9.21| | MIT | |
| 3.1.2 | ^8.0 | ^9.21| | MIT | |
| 3.1.1 | ^8.0 | ^9.21| | MIT | |
| 3.1.0 | ^8.0 | ^9.21| | MIT | |
| 3.0.1 | ^8.0 | ^9.21| | MIT | |
| 3.0.0 | ^8.0.2 | ^9.0 | MIT | |
| 2.0.5 | ^7.3 | ^7.0| | MIT | |
| 2.0.4 | ^7.3 | ^7.0| | MIT | |
| 2.0.3 | ^7.3 | ^7.0| | MIT | |
| 2.0.2 | ^7.3 | ^7.0| | MIT | |
| 2.0.1 | ^7.3 | ^7.0| | MIT | |
| 2.0.0 | ^7.3 | ^7.0| | MIT | |
| 1.1.1 | ^7.2 | ^5.8| | MIT | |
| 1.1.0 | ^7.2 | ^5.8| | MIT | |
| 1.0.8 | ^7.1.3 | MIT | ||
| 1.0.7 | ^7.1.3 | MIT | ||
| 1.0.6 | >=5.4.0 | MIT | ||
| 1.0.5 | >=5.4.0 | MIT | ||
| 1.0.4 | >=5.4.0 | MIT | ||
| 1.0.3 | >=5.4.0 | MIT | ||
| 1.0.2 | >=5.4.0 | MIT | ||
| 1.0.1 | >=5.4.0 | MIT | ||
| 1.0.0 | >=5.4.0 | MIT |