Adventure Documentation

HTML extends PlatformUtility
in package

Provides access to HTML utility functions.

Tags

Table of Contents

attributes()  : string
Turns an array into a html attributes string.
classNames()  : string
Turns an array into a html className string.
uniqueId()  : string
Get a unique id prefix with the provided argument.

Methods

attributes()

Turns an array into a html attributes string.

public attributes(array<string|int, mixed> $array) : string

The array keys will be turned into attributes. The value of the key will determine if the key is included in the final attributes string.

  $attributes = attributes([
    attr1,
    attr2 => "red",
    attr3 => false,
    attr4 => true
  ])

  // Result
  $attributes = "attr1 attr2=\"red\" attr4"
Parameters
$array : array<string|int, mixed>
Tags
Return values
string

classNames()

Turns an array into a html className string.

public classNames(array<string|int, mixed> $array) : string

The array keys will be turned into classNames. The value of the key will determine if the key is included in the final className string.

$classNames = classNames([
  class1,
  class2 => false,
  class3 => true
])

// Result
$classNames = "class1 class3"
Parameters
$array : array<string|int, mixed>
Tags
Return values
string

uniqueId()

Get a unique id prefix with the provided argument.

public uniqueId(string $key) : string

This is usefull for creating components where an id is needed so that there will never be a conflict.

Parameters
$key : string
Tags
Return values
string

        

Search results