TypeRocket v1 Pro users can now upgrade to TypeRocket v5 at their convenience.
HTML Generator
( v1 )
Make Custom Tag
echo \TypeRocket\Html\Html::el('div', ['class' => 'container'], 'Inner Content');
Will output,
<div class="container">Inner Content</div>
Make Input
echo \TypeRocket\Html\Html::input('text', 'field_name', 'the value');
Will output,
<input type="text" name="field_name" value="the value" />
Make Image
echo \TypeRocket\Html\Html::img('http://example.com/image_src.png');
Will output,
<img src="http://example.com/image_src.png" />
Make Link
echo \TypeRocket\Html\Html::a('Link Text', 'http://example.com/');
Will output,
<a href="http://example.com/">Link Text</a>
Make From
echo \TypeRocket\Html\Html::form('submit.php', 'POST');
Will output,
<from action="submit.php" method="POST"></form>
Dynamic Tags
All other tags that do not have a method natively defined can be generated using the tag name as the method name. This gives you a shorthand for the el()
method.
echo \TypeRocket\Html\Html::el('div', ['class' => 'container'], 'Inner Content');
// As..
echo \TypeRocket\Html\Html::div(['class' => 'container'], 'Inner Content');
Nesting
You can nest tags or content within other tags using nest()
.
$ul = \TypeRocket\Html\Html::ul();
$tag->nest(\TypeRocket\Html\Html::li('Item 1'));
Found a typo? Something is wrong in this documentation? Fork and edit it!