MakeTag
extends AbstractHelper
in package
Make tag view helper
Tags
Table of Contents
- $deprecatedElements : array<string|int, string>
- List of deprecated elements that should be replaced.
- $validBodyTags : array<string|int, string>
- List of all valid body tags
- $voidElements : array<string|int, string>
- List of all void tags (tags that access no innerHTML)
- __invoke() : string
- Render an HTML tag
- compileTag() : string
- Turn associative array into a string of attributes in an anchor
- verifyTagName() : void
- Verify HTML tag matches HTML spec
Properties
$deprecatedElements
List of deprecated elements that should be replaced.
protected
array<string|int, string>
$deprecatedElements
= ['acronym', 'applet', 'bgsound', 'big', 'blink', 'center', 'content', 'dir', 'font', 'frame', 'frameset', 'image', 'keygen', 'marquee', 'menuitem', 'nobr', 'noembed', 'noframes', 'param', 'plaintext', 'rb', 'rtc', 'shadow', 'spacer', 'strike', 'tt', 'xmp']
Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element Last checked: September 27, 2022
$validBodyTags
List of all valid body tags
protected
array<string|int, string>
$validBodyTags
= ['a', 'abbr', 'acronym', 'address', 'applet', 'area', 'article', 'aside', 'audio', 'b', 'base', 'bdi', 'bdo', 'bgsound', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'iframe', 'image', 'img', 'input', 'ins', 'kbd', 'keygen', 'label', 'legend', 'li', 'link', 'main', 'map', 'mark', 'marquee', 'math', 'menu', 'menuitem', 'meta', 'meter', 'nav', 'nobr', 'noembed', 'noframes', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'picture', 'plaintext', 'portal', 'pre', 'progress', 'q', 'rb', 'rp', 'rt', 'rtc', 'ruby', 's', 'samp', 'script', 'section', 'select', 'shadow', 'slot', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'svg', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr', 'xmp']
Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element Last checked: September 27, 2022
$voidElements
List of all void tags (tags that access no innerHTML)
protected
array<string|int, string>
$voidElements
= [
'area',
'base',
'br',
'col',
'embed',
'hr',
'img',
'input',
'link',
'meta',
'param',
// deprecated, but included for back-compatibility
'source',
'track',
'wbr',
]
Source: https://html.spec.whatwg.org/multipage/syntax.html#void-elements Last checked: September 27, 2022
Methods
__invoke()
Render an HTML tag
public
__invoke(string $tagName, string $contents[, string|array<string|int, mixed> $attrs = [] ][, array<string|int, mixed> $options = [] ]) : string
A string passed into $attrs will be treated like a class. These two are equivalent:
MakeTag('div', 'Success!', 'alert alert-success') MakeTag('div', 'Success!', ['class => 'alert alert-success'])
Additional options
- escapeContent: Default true, set to false to skip escaping (like for HTML).
Parameters
- $tagName : string
-
Element tag name
- $contents : string
-
Element contents (must be properly-formed HTML)
- $attrs : string|array<string|int, mixed> = []
-
Tag attributes (associative array or class name)
- $options : array<string|int, mixed> = []
-
Additional options
Return values
string —HTML for an anchor tag
compileTag()
Turn associative array into a string of attributes in an anchor
protected
compileTag(string $tagName, string $contents[, array<string|int, mixed> $attrs = [] ][, array<string|int, mixed> $options = [] ]) : string
Additional options
- escapeContent: Default true, set to false to skip escaping (like for HTML).
Parameters
- $tagName : string
-
HTML tag name
- $contents : string
-
InnerHTML
- $attrs : array<string|int, mixed> = []
-
Tag attributes (associative array)
- $options : array<string|int, mixed> = []
-
Additional options
Return values
string —verifyTagName()
Verify HTML tag matches HTML spec
protected
verifyTagName(string $tagName) : void
Parameters
- $tagName : string
-
Element tag name