October\Rain\Html\HtmlBuilder

Source: ~/vendor/october/rain/src/Html/HtmlBuilder.php

Html builder

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

Protected properties

protected Illuminate\Routing\UrlGenerator $url

The URL generator instance.

protected static array $macros

The registered string macros.

Public methods

public mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters
  • string $method
  • array $parameters

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

Dynamically handle calls to the class.

Parameters
  • string $method
  • array $parameters

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

Create a new HTML builder instance.

Parameters
  • Illuminate\Routing\UrlGenerator $url

public string attributes(array $attributes)

Build an HTML attribute string from an array.

Parameters
  • array $attributes

public static string clean(string $html)

Cleans HTML to prevent most XSS attacks.

Parameters
  • string $html - HTML

public string decode(string $value)

Convert entities to HTML characters.

Parameters
  • string $value

public string email(string $email)

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

Parameters
  • string $email

public string entities(string $value)

Convert an HTML string to entities.

Parameters
  • string $value

public static bool hasMacro(string $name)

Checks if macro is registered.

Parameters
  • string $name

public 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

public static string limit(string $html, int $maxLength=100, string $end='...')

Limits HTML with specific length with a proper tag handling.

Parameters
  • string $html - HTML string to limit
  • int $maxLength - String length to truncate at
  • string $end

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

Generate a HTML link.

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

public 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

public 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

public 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

public 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

public static void macro(string $name, object|callable $macro)

Register a custom macro.

Parameters
  • string $name
  • object|callable $macro

public 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

public static void mixin(object $mixin)

Mix another object into the class.

Parameters
  • object $mixin

public string obfuscate(string $value)

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

Parameters
  • string $value

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

Generate an ordered list of items.

Parameters
  • array $list
  • array $attributes

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

Generate a link to a JavaScript file.

Parameters
  • string $url
  • array $attributes
  • bool $secure

public string secureLink(string $url, string $title=NULL, array $attributes=array())

Generate a HTTPS HTML link.

Parameters
  • string $url
  • string $title
  • array $attributes

public static string strip($string $string)

Removes HTML from a string

Parameters
  • $string $string - String to strip HTML from

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

Generate a link to a CSS file.

Parameters
  • string $url
  • array $attributes
  • bool $secure

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

Generate an un-ordered list of items.

Parameters
  • array $list
  • array $attributes

Protected methods

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

Build a single attribute element.

Parameters
  • string $key
  • string $value

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

Create a listing HTML element.

Parameters
  • string $type
  • array $list
  • array $attributes

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

Create the HTML for a listing element.

Parameters
  • mixed $key
  • string $type
  • string $value

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

Create the HTML for a nested listing attribute.

Parameters
  • mixed $key
  • string $type
  • string $value