Html Component contains methods that can be useful when working with HTML.
Installs: 3 191
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^7.1.3
This package is auto-updated.
Last update: 2024-10-25 11:39:44 UTC
README
Html Component contains methods that can be useful when working with HTML.
Installation
composer require flextype-components/html
Usage
use Flextype\Component\Html\Html;
Registers a custom macro.
// 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.
echo Html::toText('test');
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
echo Html::nbsp(2);
Create an arrow
echo Html::arrow('right');
Create HTML link anchor.
echo Html::anchor('About', 'http://sitename.com/about');
Create HTML tag
echo Html::heading('Title', 1);
Generate document type declarations
echo Html::doctype('html5');
Create image
echo Html::image('data/files/pic1.jpg');
Obfuscate an e-mail address to prevent spam-bots from sniffing it.
echo Html::email('hello@flextype.org');
Obfuscate a string to prevent spam-bots from sniffing it.
This method obfuscate the value, randomly convert each
letter to its entity or hexadecimal representation, keeping a
bot from sniffing the randomly obfuscated letters.
echo Html::obfuscate('hello@flextype.org');
License
See LICENSE