umbrella / tag-builder
TagBuilder is a component to help you to build html tags
Installs: 23 148
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 6
Forks: 1
Open Issues: 0
Requires
README
What is it?
TagBuilder is a component to help you to build html tags. But why use it to render tags instead of just write them? Well the tag builder sets a pattern of how we need to handle html elements, this avoids html errors and copy and paste code.
Install
{ "require": { "umbrella/tag-builder": "~1.0" } }
Usage
Build a link tag.
$linkTag = new \Umbrella\TagBuilder\TagBuilder('a'); //Adds a href attribute to the tag $linkTag->mergeAttribute('href', '#'); //Adds a css class to the tag $linkTag->addCssClass('your-custom-css-class'); //Adds a text or a html to some tag $linkTag->setInnerHtml('Your link text'); //Renders the tag... echo $linkTag->toString(\Umbrella\TagBuilder\TagRenderMode::NORMAL); // ... or render like this echo $linkTag; //Both will print <a href="#" class="your-custom-css-class">Your link text</a>
We have many render modes available like:
\Umbrella\TagBuilder\TagRenderMode::NORMAL \Umbrella\TagBuilder\TagRenderMode::START_TAG \Umbrella\TagBuilder\TagRenderMode::END_TAG \Umbrella\TagBuilder\TagRenderMode::SELF_CLOSING
Testing
$ phpunit
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.