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.
{
"require": {
"umbrella/tag-builder": "~1.0"
}
}
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
$ phpunit
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.