class HtmlBuilder (View source)

Traits

Properties

static protected array $macros The registered string macros. from MacroableTrait
protected UrlGenerator $url The URL generator instance.

Methods

static void
macro(string $name, callable $macro)

Register a custom macro.

static boolean
hasMacro(string $name)

Checks if macro is registered

static mixed
__callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

mixed
__call(string $method, array $parameters)

Dynamically handle calls to the class.

void
__construct(UrlGenerator $url = null)

Create a new HTML builder instance.

string
entities(string $value)

Convert an HTML string to entities.

string
decode(string $value)

Convert entities to HTML characters.

string
script(string $url, array $attributes = array(), bool $secure = null)

Generate a link to a JavaScript file.

string
style(string $url, array $attributes = array(), bool $secure = null)

Generate a link to a CSS file.

string
image(string $url, string $alt = null, array $attributes = array(), bool $secure = null)

Generate an HTML image element.

string
link(string $url, string $title = null, array $attributes = array(), bool $secure = null)

Generate a HTML link.

string
secureLink(string $url, string $title = null, array $attributes = array())

Generate a HTTPS HTML link.

string
linkAsset(string $url, string $title = null, array $attributes = array(), bool $secure = null)

Generate a HTML link to an asset.

string
linkSecureAsset(string $url, string $title = null, array $attributes = array())

Generate a HTTPS HTML link to an asset.

string
linkRoute(string $name, string $title = null, array $parameters = array(), array $attributes = array())

Generate a HTML link to a named route.

string
linkAction(string $action, string $title = null, array $parameters = array(), array $attributes = array())

Generate a HTML link to a controller action.

string
mailto(string $email, string $title = null, array $attributes = array())

Generate a HTML link to an email address.

string
email(string $email)

Obfuscate an e-mail address to prevent spam-bots from sniffing it.

string
ol(array $list, array $attributes = array())

Generate an ordered list of items.

string
ul(array $list, array $attributes = array())

Generate an un-ordered list of items.

string
listing(string $type, array $list, array $attributes = array())

Create a listing HTML element.

string
listingElement(mixed $key, string $type, string $value)

Create the HTML for a listing element.

string
nestedListing(mixed $key, string $type, string $value)

Create the HTML for a nested listing attribute.

string
attributes(array $attributes)

Build an HTML attribute string from an array.

string
attributeElement(string $key, string $value)

Build a single attribute element.

string
obfuscate(string $value)

Obfuscate a string to prevent spam-bots from sniffing it.

Details

static void macro(string $name, callable $macro)

Register a custom macro.

Parameters

string $name
callable $macro

Return Value

void

static boolean hasMacro(string $name)

Checks if macro is registered

Parameters

string $name

Return Value

boolean

static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

void __construct(UrlGenerator $url = null)

Create a new HTML builder instance.

Parameters

UrlGenerator $url

Return Value

void

string entities(string $value)

Convert an HTML string to entities.

Parameters

string $value

Return Value

string

string decode(string $value)

Convert entities to HTML characters.

Parameters

string $value

Return Value

string

string script(string $url, array $attributes = array(), bool $secure = null)

Generate a link to a JavaScript file.

Parameters

string $url
array $attributes
bool $secure

Return Value

string

string style(string $url, array $attributes = array(), bool $secure = null)

Generate a link to a CSS file.

Parameters

string $url
array $attributes
bool $secure

Return Value

string

string image(string $url, string $alt = null, array $attributes = array(), bool $secure = null)

Generate an HTML image element.

Parameters

string $url
string $alt
array $attributes
bool $secure

Return Value

string

Generate a HTML link.

Parameters

string $url
string $title
array $attributes
bool $secure

Return Value

string

Generate a HTTPS HTML link.

Parameters

string $url
string $title
array $attributes

Return Value

string

string linkAsset(string $url, string $title = null, array $attributes = array(), bool $secure = null)

Generate a HTML link to an asset.

Parameters

string $url
string $title
array $attributes
bool $secure

Return Value

string

string linkSecureAsset(string $url, string $title = null, array $attributes = array())

Generate a HTTPS HTML link to an asset.

Parameters

string $url
string $title
array $attributes

Return Value

string

string linkRoute(string $name, string $title = null, array $parameters = array(), array $attributes = array())

Generate a HTML link to a named route.

Parameters

string $name
string $title
array $parameters
array $attributes

Return Value

string

string linkAction(string $action, string $title = null, array $parameters = array(), array $attributes = array())

Generate a HTML link to a controller action.

Parameters

string $action
string $title
array $parameters
array $attributes

Return Value

string

string mailto(string $email, string $title = null, array $attributes = array())

Generate a HTML link to an email address.

Parameters

string $email
string $title
array $attributes

Return Value

string

string email(string $email)

Obfuscate an e-mail address to prevent spam-bots from sniffing it.

Parameters

string $email

Return Value

string

string ol(array $list, array $attributes = array())

Generate an ordered list of items.

Parameters

array $list
array $attributes

Return Value

string

string ul(array $list, array $attributes = array())

Generate an un-ordered list of items.

Parameters

array $list
array $attributes

Return Value

string

protected string listing(string $type, array $list, array $attributes = array())

Create a listing HTML element.

Parameters

string $type
array $list
array $attributes

Return Value

string

protected string listingElement(mixed $key, string $type, string $value)

Create the HTML for a listing element.

Parameters

mixed $key
string $type
string $value

Return Value

string

protected string nestedListing(mixed $key, string $type, string $value)

Create the HTML for a nested listing attribute.

Parameters

mixed $key
string $type
string $value

Return Value

string

string attributes(array $attributes)

Build an HTML attribute string from an array.

Parameters

array $attributes

Return Value

string

protected string attributeElement(string $key, string $value)

Build a single attribute element.

Parameters

string $key
string $value

Return Value

string

string obfuscate(string $value)

Obfuscate a string to prevent spam-bots from sniffing it.

Parameters

string $value

Return Value

string