New! TypeRocket v5 is now available. See docs.
Access all of Typerocket. Get Pro.
HTML Generator
( v4 )
Make Custom Tag
Making a tag is simple with the Generator
class.
$gen = new \TypeRocket\Html\Generator();
$gen->newElement('div', ['class' => 'container'], 'Inner Content');
echo $gen;
Will output,
<div class="container">Inner Content</div>
Make Input
$gen = new \TypeRocket\Html\Generator();
$gen->newInput('text', 'field_name', 'the value');
echo $gen;
Will output,
<input type="text" name="field_name" value="the value" />
Make Image
$gen = new \TypeRocket\Html\Generator();
$gen->newImage('http://example.com/image_src.png');
echo $gen;
Will output,
<img src="http://example.com/image_src.png" />
Make Link
$gen = new \TypeRocket\Html\Generator();
$gen->newLink('Link Text', 'http://example.com/');
echo $gen;
Will output,
<a href="http://example.com/">Link Text</a>
Found a typo? Something is wrong in this documentation? Fork and edit it!