You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Markup class provides a simple structure for any standard markup which can be later rendered as string.
Creating a markup
To make a markup, simply create a new instance of the desired class with 3 possible attributes:
Tag (required)
Contents (may be another markup, or a simple string)
Attributes (provided as associative array)
$markup = Markup::create('report', 'Lorem ipsum dolor sit amet.', ['created' => date('Y-m-d')]);
echo $markup; // <report created="2019-10-21">Lorem ipsum dolor sit amet.</report>
Chainable methods
All methods except render() will return the object itself, so may be chained until it is turned into a string.
$markup->content('footer_key', Markup::create('footer', 'Footer of the report.'))->attr('expires', 'never');
<report created="2019-10-21" expires="never">Lorem ipsum dolor sit amet.<footer>Footer of the report.</footer></report>
Rendering markups
Just turn the $markup instance into string or call the render() method: