class Template

Properties

protected TemplateInspector $inspector
protected bool $isNormalized
protected string $template

Methods

__construct(string $template)

Constructor

mixed
__call($methodName, $args)

Handle calls to undefined methods

string
__toString()

Return this template's content

asDOM()

Return the content of this template as a DOMDocument

array
getCSSNodes()

Return all the nodes in this template whose content type is CSS

getInspector()

Return an instance of TemplateInspector based on this template's content

array
getJSNodes()

Return all the nodes in this template whose content type is JavaScript

array
getURLNodes()

Return all the nodes in this template whose value is an URL

array
getParameters()

Return a list of parameters in use in this template

bool
isNormalized(bool $bool = null)

Set and/or return whether this template has been normalized

void
normalize(TemplateNormalizer $templateNormalizer)

Normalize this template's content

void
replaceTokens(string $regexp, callable $fn)

Replace parts of this template that match given regexp

void
setContent(string $template)

Replace this template's content

Details

at line 39
__construct(string $template)

Constructor

Parameters

string $template

This template's content

at line 51
mixed __call($methodName, $args)

Handle calls to undefined methods

Forwards calls to this template's TemplateInspector instance

Parameters

$methodName
$args

Return Value

mixed

at line 61
string __toString()

Return this template's content

Return Value

string

at line 73
DOMDocument asDOM()

Return the content of this template as a DOMDocument

NOTE: the content is wrapped in an node

Return Value

DOMDocument

at line 90
array getCSSNodes()

Return all the nodes in this template whose content type is CSS

Return Value

array

at line 100
TemplateInspector getInspector()

Return an instance of TemplateInspector based on this template's content

Return Value

TemplateInspector

at line 115
array getJSNodes()

Return all the nodes in this template whose content type is JavaScript

Return Value

array

at line 125
array getURLNodes()

Return all the nodes in this template whose value is an URL

Return Value

array

at line 135
array getParameters()

Return a list of parameters in use in this template

Return Value

array

Alphabetically sorted list of unique parameter names

at line 146
bool isNormalized(bool $bool = null)

Set and/or return whether this template has been normalized

Parameters

bool $bool

If present, the new value for this template's isNormalized flag

Return Value

bool

Whether this template has been normalized

at line 162
void normalize(TemplateNormalizer $templateNormalizer)

Normalize this template's content

Parameters

TemplateNormalizer $templateNormalizer

Return Value

void

at line 176
void replaceTokens(string $regexp, callable $fn)

Replace parts of this template that match given regexp

Parameters

string $regexp

Regexp for matching parts that need replacement

callable $fn

Callback used to get the replacement

Return Value

void

at line 189
void setContent(string $template)

Replace this template's content

Parameters

string $template

New content

Return Value

void