Constants

SKIP_VARIABLES_IF_REGEXP_START

SKIP_VARIABLES_IF_REGEXP_START ='/((var|const|let)\s+)?[A-Za-z0-9_\.\[\]"\']+\s?=\s+?{/'

If an inline script starts with a given expression, let's test the complete script if it is a variable (CDATA).

SKIP_VARIABLES_IF_REGEXP_END

SKIP_VARIABLES_IF_REGEXP_END ='/};?$/'

Properties

$finder

$finder :

Type

$originalMatch

$originalMatch :

Type

$tag

$tag :

Type

$attributes

$attributes :

Type

$dataUrlAttributes

$dataUrlAttributes :array<mixed,string>

Attributes, which are represented as data URL.

Type

array<mixed,string>

$changed

$changed :

Type

$beforeTag

$beforeTag :

Type

$afterTag

$afterTag :

Type

$doOmit

$doOmit :

Type

$script

$script :

Type

Methods

__construct()

__construct(\DevOwl\FastHtmlTag\finder\ScriptInlineFinder  $finder,string  $originalMatch,array  $attributes,string  $script)

C'tor.

Parameters

\DevOwl\FastHtmlTag\finder\ScriptInlineFinder $finder
string $originalMatch
array $attributes
string $script

render()

render(): string

Render this match to valid HTML. Please pass your result to `encloseRendered` and return that result.

Returns

string

omit()

omit()

Omit the rendering.

isOmitted()

isOmitted()

Should we omit the rendering for this node?

isAttributeDataUrl()

isAttributeDataUrl(string  $key)

Check if a given attribute is a data URL and return the mime type.

Parameters

string $key

isSelfClosing()

isSelfClosing()

Check if the original match is a self-closing HTML tag. E.g. `<link />` vs. `<link></link>`.

getAttribute()

getAttribute(string  $key,mixed  $default = null)

Get attribute by key.

Parameters

string $key
mixed $default

hasAttribute()

hasAttribute(string  $key)

Check if the match has a given attribute.

Parameters

string $key

calculateUniqueKey()

calculateUniqueKey(array<mixed,string>  $idKeys = array('id'),array<mixed,string[]>  $looseAttributes = array()): string|null

Calculate a unique key for this match.

Parameters

array<mixed,string> $idKeys

Consider ID keys as unique (ordered by priority)

array<mixed,string[]> $looseAttributes

Returns

string|null —

Can return null if we cannot calculate a unique key for this container

setAttribute()

setAttribute(string  $key,mixed|null  $value,null|false|string  $dataUrlTransformation = null)

Set attribute by key and value.

Parameters

string $key
mixed|null $value
null|false|string $dataUrlTransformation

Pass a mime type so it gets transformed to base64-encoded attribute value

setAttributes()

setAttributes(array  $attributes)

Setter.

Parameters

array $attributes

setTag()

setTag(string  $string)

Setter. Use this with caution! Due to the fact, this can break your HTML code, if the finder does not hold the end tag!

Parameters

string $string

setBeforeTag()

setBeforeTag(string  $string)

Setter.

Attention: If setting this, make sure, your match does no longer match again so you do not end up in an endless loop.

Parameters

string $string

setAfterTag()

setAfterTag(string  $string)

Setter.

Attention: If setting this, make sure, your match does no longer match again so you do not end up in an endless loop.

Parameters

string $string

setChanged()

setChanged(boolean  $status)

Indicate that the match has a change. You need to mark this to `true` to apply changes to your HTML.

Parameters

boolean $status

getOriginalMatch()

getOriginalMatch()

Getter.

getTag()

getTag()

Getter.

getAttributes()

getAttributes()

Getter.

hasChanged()

hasChanged()

Getter.

getBeforeTag()

getBeforeTag()

Getter.

getAfterTag()

getAfterTag()

Getter.

isJavascript()

isJavascript()

Check if the script is javascript.

isCData()

isCData()

Check if the script is a `CDATA`.

isScriptOnlyVariableAssignment()

isScriptOnlyVariableAssignment(array<mixed,string>  $variableNames = array(),boolean  $compute = true)

Check if the script only contains a variable assignment.

Parameters

array<mixed,string> $variableNames

Pass an optional array of variable names or regular expressions

boolean $compute

If true, it will try to parse the variable

setScript()

setScript(string  $script)

Setter.

Parameters

string $script

getScript()

getScript()

Getter.

transformBase64DataUrls()

transformBase64DataUrls()

Automatically transform base64-encoded data URLs and memorize in `$this->dataUrlAttributes` for rendering process.

renderAttributes()

renderAttributes()

Render attributes to a single string so it can be e.g. used with `<div %s`.

encloseRendered()

encloseRendered(string  $html)

Use `beforeTag` and `afterTag`.

Parameters

string $html