HtmlBuilder

Html builder

 class Winter\Storm\Html\HtmlBuilder

Extension of illuminate/html, injects a session key to each form opening.

Traits

Properties

protected $url : Illuminate\Routing\UrlGenerator

The URL generator instance.

Methods

public __construct (Illuminate\Routing\UrlGenerator $url = null) : void

Create a new HTML builder instance.

Parameters
Property Description
$url
Illuminate\Routing\UrlGenerator
Returns
void

public attributes (array $attributes) : string

Build an HTML attribute string from an array.

Parameters
Property Description
$attributes
array
Returns
string

public static clean (string $html) : string

Cleans HTML to prevent most XSS attacks.

Parameters
Property Description
$html
string

HTML

Returns
string

Cleaned HTML

public decode (string $value) : string

Convert entities to HTML characters.

Parameters
Property Description
$value
string
Returns
string

public email (string $email) : string

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

Parameters
Property Description
$email
string
Returns
string

public entities (string $value) : string

Convert an HTML string to entities.

Parameters
Property Description
$value
string
Returns
string

public image (string $url, string $alt = null, array $attributes = [], bool $secure = null) : string

Generate an HTML image element.

Parameters
Property Description
$url
string
$alt
string
$attributes
array
$secure
bool
Returns
string

public static limit (string $html, integer $maxLength = 100, string $end = "...") : string

Limits HTML with specific length with a proper tag handling.

Parameters
Property Description
$html
string

HTML string to limit

$maxLength
integer

String length to truncate at

$end
string
Returns
string

public link (string $url, string | false | null $title = null, array $attributes = [], bool $secure = null) : string

Generate a HTML link.

Parameters
Property Description
$url
string
$title
string | false | null
$attributes
array
$secure
bool
Returns
string

public linkAction (string $action, string $title = null, array $parameters = [], array $attributes = []) : string

Generate a HTML link to a controller action.

Parameters
Property Description
$action
string
$title
string
$parameters
array
$attributes
array
Returns
string

public linkAsset (string $url, string $title = null, array $attributes = [], bool $secure = null) : string

Generate a HTML link to an asset.

Parameters
Property Description
$url
string
$title
string
$attributes
array
$secure
bool
Returns
string

public linkRoute (string $name, string $title = null, array $parameters = [], array $attributes = []) : string

Generate a HTML link to a named route.

Parameters
Property Description
$name
string
$title
string
$parameters
array
$attributes
array
Returns
string

public linkSecureAsset (string $url, string $title = null, array $attributes = []) : string

Generate a HTTPS HTML link to an asset.

Parameters
Property Description
$url
string
$title
string
$attributes
array
Returns
string

public mailto (string $email, string $title = null, array $attributes = []) : string

Generate a HTML link to an email address.

Parameters
Property Description
$email
string
$title
string
$attributes
array
Returns
string

public obfuscate (string $value) : string

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

Parameters
Property Description
$value
string
Returns
string

public ol (array $list, array $attributes = []) : string

Generate an ordered list of items.

Parameters
Property Description
$list
array
$attributes
array
Returns
string

public script (string $url, array $attributes = [], bool $secure = null) : string

Generate a link to a JavaScript file.

Parameters
Property Description
$url
string
$attributes
array
$secure
bool
Returns
string

public secureLink (string $url, string $title = null, array $attributes = []) : string

Generate a HTTPS HTML link.

Parameters
Property Description
$url
string
$title
string
$attributes
array
Returns
string

public static strip (string $string) : string

Removes HTML from a string

Parameters
Property Description
$string
string

String to strip HTML from

Returns
string

public style (string $url, array $attributes = [], bool $secure = null) : string

Generate a link to a CSS file.

Parameters
Property Description
$url
string
$attributes
array
$secure
bool
Returns
string

public ul (array $list, array $attributes = []) : string

Generate an un-ordered list of items.

Parameters
Property Description
$list
array
$attributes
array
Returns
string

protected attributeElement (string $key, string | array | null $value = null) : string | null

Build a single attribute element.

Parameters
Property Description
$key
string
$value
string | array | null
Returns
string | null

protected static getReadableLength (string $str) : int

Gets the readable length of a string for limit calculations.

Considers multiple spaces and line breaks to be 1 character, regardless of OS.

Parameters
Property Description
$str
string
Returns
int

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

Create a listing HTML element.

Parameters
Property Description
$type
string
$list
array
$attributes
array
Returns
string

protected listingElement (mixed $key, string $type, string | array $value) : string

Create the HTML for a listing element.

Parameters
Property Description
$key
mixed
$type
string
$value
string | array
Returns
string

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

Create the HTML for a nested listing attribute.

Parameters
Property Description
$key
mixed
$type
string
$value
array
Returns
string
Copyright © 2024 Winter CMS