Skip to content

Html Component contains methods that can be useful when working with HTML.

License

Notifications You must be signed in to change notification settings

flextype-components/html

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Html Component

version MIT License

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

About

Html Component contains methods that can be useful when working with HTML.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages