Documentation

Html


The html helper contains methods that assist in working with html.


macro(string $name, Closure $macro)


Registers a custom macro.


// Registering a Htmlk macro
Html::macro('my_element', function() {
   return '';
});
// Calling a custom Html macro
echo Html::my_element();
// Registering a Html macro with parameters
Html::macro('my_element', function(id = '') {
   return '';
});
// Calling a custom Html macro with parameters
echo Html::my_element('monstra');

chars(string $value, [boolean $double_encode = true])


Convert special characters to HTML entities. All untrusted content should be passed through this method to prevent XSS injections.


echo Html::chars($username);

attributes([array $attributes = null])


Compiles an array of HTML attributes into an attribute string. Attributes will be sorted using Html::$attribute_order for consistency.


echo '
'.$content.'
';

br([array $num = 1])


Create br tags.


echo Html::br(2);

nbsp([array $num = 1])


Create nbsp


echo Html::nbsp(2);

arrow(string $direction)


Create an arrow


echo Html::arrow('right');
echo Html::arrow('left');
echo Html::arrow('up');
echo Html::arrow('down');

anchor(string $title, [string $url = null, array $attributes = null]])


Create HTML link anchor.


echo Html::anchor('About', 'http://sitename.com/about');

heading(string $title, [integer $h = 1, array $attributes = null]])


Create HTML tag.


echo Html::heading('Title', 1);

doctype([string $type = 'html5'])


Generate document type declarations.


echo Html::doctype('html5');

image(string $file,[array $attributes = null])


Create image.


echo Html::image('data/files/pic1.jpg');

toText(string $str)


Convert html to plain text.


echo Html::toText('test');