Html Component
, (*1)
Html Component contains methods that can be useful when working with HTML., (*2)
Installation
composer require flextype-components/html
Usage
use Flextype\Component\Html\Html;
Registers a custom macro., (*3)
// Registering a Html macro
Html::macro('my_element', function() {
return '<element id="flextype">';
});
// 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('flextype');
Convert special characters to HTML entities. All untrusted content
should be passed through this method to prevent XSS injections., (*4)
echo Html::toText('test');
Compiles an array of HTML attributes into an attribute string.
Attributes will be sorted using Html::$attribute_order for consistency., (*5)
echo '<div'.Html::attributes($attrs).'>'.$content.'</div>';
Create br tags, (*6)
echo Html::br(2);
Create , (*7)
echo Html::nbsp(2);
Create an arrow, (*8)
echo Html::arrow('right');
Create HTML link anchor., (*9)
echo Html::anchor('About', 'http://sitename.com/about');
Create HTML tag, (*10)
echo Html::heading('Title', 1);
Generate document type declarations, (*11)
echo Html::doctype('html5');
Create image, (*12)
echo Html::image('data/files/pic1.jpg');
Obfuscate an e-mail address to prevent spam-bots from sniffing it., (*13)
echo Html::email('hello@flextype.org');
Obfuscate a string to prevent spam-bots from sniffing it., (*14)
This method obfuscate the value, randomly convert each
letter to its entity or hexadecimal representation, keeping a
bot from sniffing the randomly obfuscated letters., (*15)
echo Html::obfuscate('hello@flextype.org');
License
See LICENSE, (*16)