HtmlBuilder
in package
Uses
Macroable
Html builder
Extension of illuminate/html, injects a session key to each form opening.
Tags
Table of Contents
- $macros : array<string|int, mixed>
- The registered string macros.
- $url : UrlGenerator
- The URL generator instance.
- __call() : mixed
- Dynamically handle calls to the class.
- __callStatic() : mixed
- Dynamically handle calls to the class.
- __construct() : void
- Create a new HTML builder instance.
- attributes() : string
- Build an HTML attribute string from an array.
- clean() : string
- Cleans HTML to prevent most XSS attacks.
- decode() : string
- Convert entities to HTML characters.
- email() : string
- Obfuscate an e-mail address to prevent spam-bots from sniffing it.
- entities() : string
- Convert an HTML string to entities.
- hasMacro() : bool
- Checks if macro is registered.
- image() : string
- Generate an HTML image element.
- limit() : string
- Limits HTML with specific length with a proper tag handling.
- link() : string
- Generate a HTML link.
- linkAction() : string
- Generate a HTML link to a controller action.
- linkAsset() : string
- Generate a HTML link to an asset.
- linkRoute() : string
- Generate a HTML link to a named route.
- linkSecureAsset() : string
- Generate a HTTPS HTML link to an asset.
- macro() : void
- Register a custom macro.
- mailto() : string
- Generate a HTML link to an email address.
- mixin() : void
- Mix another object into the class.
- obfuscate() : string
- Obfuscate a string to prevent spam-bots from sniffing it.
- ol() : string
- Generate an ordered list of items.
- script() : string
- Generate a link to a JavaScript file.
- secureLink() : string
- Generate a HTTPS HTML link.
- strip() : string
- Removes HTML from a string
- style() : string
- Generate a link to a CSS file.
- ul() : string
- Generate an un-ordered list of items.
- attributeElement() : string|void
- Build a single attribute element.
- listing() : string
- Create a listing HTML element.
- listingElement() : string
- Create the HTML for a listing element.
- nestedListing() : string
- Create the HTML for a nested listing attribute.
Properties
$macros
The registered string macros.
protected
static array<string|int, mixed>
$macros
= []
$url
The URL generator instance.
protected
UrlGenerator
$url
Methods
__call()
Dynamically handle calls to the class.
public
__call(string $method, array<string|int, mixed> $parameters) : mixed
Parameters
- $method : string
- $parameters : array<string|int, mixed>
Tags
Return values
mixed —__callStatic()
Dynamically handle calls to the class.
public
static __callStatic(string $method, array<string|int, mixed> $parameters) : mixed
Parameters
- $method : string
- $parameters : array<string|int, mixed>
Tags
Return values
mixed —__construct()
Create a new HTML builder instance.
public
__construct([UrlGenerator $url = null ]) : void
Parameters
- $url : UrlGenerator = null
Return values
void —attributes()
Build an HTML attribute string from an array.
public
attributes(array<string|int, mixed> $attributes) : string
Parameters
- $attributes : array<string|int, mixed>
Return values
string —clean()
Cleans HTML to prevent most XSS attacks.
public
static clean(string $html) : string
Parameters
- $html : string
-
HTML
Return values
string —Cleaned HTML
decode()
Convert entities to HTML characters.
public
decode(string $value) : string
Parameters
- $value : string
Return values
string —email()
Obfuscate an e-mail address to prevent spam-bots from sniffing it.
public
email(string $email) : string
Parameters
- $email : string
Return values
string —entities()
Convert an HTML string to entities.
public
entities(string $value) : string
Parameters
- $value : string
Return values
string —hasMacro()
Checks if macro is registered.
public
static hasMacro(string $name) : bool
Parameters
- $name : string
Return values
bool —image()
Generate an HTML image element.
public
image(string $url[, string $alt = null ][, array<string|int, mixed> $attributes = [] ][, bool $secure = null ]) : string
Parameters
- $url : string
- $alt : string = null
- $attributes : array<string|int, mixed> = []
- $secure : bool = null
Return values
string —limit()
Limits HTML with specific length with a proper tag handling.
public
static limit(string $html[, int $maxLength = 100 ][, string $end = '...' ]) : string
Parameters
- $html : string
-
HTML string to limit
- $maxLength : int = 100
-
String length to truncate at
- $end : string = '...'
Return values
string —link()
Generate a HTML link.
public
link(string $url[, string $title = null ][, array<string|int, mixed> $attributes = [] ][, bool $secure = null ]) : string
Parameters
- $url : string
- $title : string = null
- $attributes : array<string|int, mixed> = []
- $secure : bool = null
Return values
string —linkAction()
Generate a HTML link to a controller action.
public
linkAction(string $action[, string $title = null ][, array<string|int, mixed> $parameters = [] ][, array<string|int, mixed> $attributes = [] ]) : string
Parameters
- $action : string
- $title : string = null
- $parameters : array<string|int, mixed> = []
- $attributes : array<string|int, mixed> = []
Return values
string —linkAsset()
Generate a HTML link to an asset.
public
linkAsset(string $url[, string $title = null ][, array<string|int, mixed> $attributes = [] ][, bool $secure = null ]) : string
Parameters
- $url : string
- $title : string = null
- $attributes : array<string|int, mixed> = []
- $secure : bool = null
Return values
string —linkRoute()
Generate a HTML link to a named route.
public
linkRoute(string $name[, string $title = null ][, array<string|int, mixed> $parameters = [] ][, array<string|int, mixed> $attributes = [] ]) : string
Parameters
- $name : string
- $title : string = null
- $parameters : array<string|int, mixed> = []
- $attributes : array<string|int, mixed> = []
Return values
string —linkSecureAsset()
Generate a HTTPS HTML link to an asset.
public
linkSecureAsset(string $url[, string $title = null ][, array<string|int, mixed> $attributes = [] ]) : string
Parameters
- $url : string
- $title : string = null
- $attributes : array<string|int, mixed> = []
Return values
string —macro()
Register a custom macro.
public
static macro(string $name, object|callable $macro) : void
Parameters
- $name : string
- $macro : object|callable
Return values
void —mailto()
Generate a HTML link to an email address.
public
mailto(string $email[, string $title = null ][, array<string|int, mixed> $attributes = [] ]) : string
Parameters
- $email : string
- $title : string = null
- $attributes : array<string|int, mixed> = []
Return values
string —mixin()
Mix another object into the class.
public
static mixin(object $mixin) : void
Parameters
- $mixin : object
Return values
void —obfuscate()
Obfuscate a string to prevent spam-bots from sniffing it.
public
obfuscate(string $value) : string
Parameters
- $value : string
Return values
string —ol()
Generate an ordered list of items.
public
ol(array<string|int, mixed> $list[, array<string|int, mixed> $attributes = [] ]) : string
Parameters
- $list : array<string|int, mixed>
- $attributes : array<string|int, mixed> = []
Return values
string —script()
Generate a link to a JavaScript file.
public
script(string $url[, array<string|int, mixed> $attributes = [] ][, bool $secure = null ]) : string
Parameters
- $url : string
- $attributes : array<string|int, mixed> = []
- $secure : bool = null
Return values
string —secureLink()
Generate a HTTPS HTML link.
public
secureLink(string $url[, string $title = null ][, array<string|int, mixed> $attributes = [] ]) : string
Parameters
- $url : string
- $title : string = null
- $attributes : array<string|int, mixed> = []
Return values
string —strip()
Removes HTML from a string
public
static strip( $string) : string
Parameters
Return values
string —style()
Generate a link to a CSS file.
public
style(string $url[, array<string|int, mixed> $attributes = [] ][, bool $secure = null ]) : string
Parameters
- $url : string
- $attributes : array<string|int, mixed> = []
- $secure : bool = null
Return values
string —ul()
Generate an un-ordered list of items.
public
ul(array<string|int, mixed> $list[, array<string|int, mixed> $attributes = [] ]) : string
Parameters
- $list : array<string|int, mixed>
- $attributes : array<string|int, mixed> = []
Return values
string —attributeElement()
Build a single attribute element.
protected
attributeElement(string $key, string $value) : string|void
Parameters
- $key : string
- $value : string
Return values
string|void —listing()
Create a listing HTML element.
protected
listing(string $type, array<string|int, mixed> $list[, array<string|int, mixed> $attributes = [] ]) : string
Parameters
- $type : string
- $list : array<string|int, mixed>
- $attributes : array<string|int, mixed> = []
Return values
string —listingElement()
Create the HTML for a listing element.
protected
listingElement(mixed $key, string $type, string $value) : string
Parameters
- $key : mixed
- $type : string
- $value : string
Return values
string —nestedListing()
Create the HTML for a nested listing attribute.
protected
nestedListing(mixed $key, string $type, array<string|int, mixed> $value) : string
Parameters
- $key : mixed
- $type : string
- $value : array<string|int, mixed>