The html helper contains methods that assist in working with html.
Registers a custom macro.
// Registering a Html macro
Html::macro('my_element', function() {
return '<element id="monstra">';
});
// Calling a custom Html macro
echo Html::my_element();
// Registering a Html macro with parameters
Html::macro('my_element', function(id = '') {
return '<element id="'.$id.'">';
});
// Calling a custom Html macro with parameters
echo Html::my_element('monstra');
Convert special characters to HTML entities. All untrusted content should be passed through this method to prevent XSS injections.
echo Html::chars($username);
Compiles an array of HTML attributes into an attribute string. Attributes will be sorted using Html::$attribute_order for consistency.
echo '<div'.Html::attributes($attrs).'>'.$content.'</div>';
Create br tags.
echo Html::br(2);
Create nbsp
echo Html::nbsp(2);
Create an arrow
echo Html::arrow('right');
echo Html::arrow('left');
echo Html::arrow('up');
echo Html::arrow('down');
Create HTML link anchor.
echo Html::anchor('About', 'http://sitename.com/about');
Create HTML
echo Html::heading('Title', 1);
Generate document type declarations.
echo Html::doctype('html5');
Create image.
echo Html::image('data/files/pic1.jpg');
Convert html to plain text.
echo Html::toText('test');