abstract class TemplateHelper

Constants

XMLNS_XSL

XSL namespace

Methods

static array
getParametersFromXSL(string $xsl)

Return a list of parameters in use in given XSL

static string
highlightNode(DOMNode $node, string $prepend, string $append)

Highlight the source of a node inside of a template

static void
replaceHomogeneousTemplates(array $templates, int $minCount = 3)

Replace simple templates (in an array, in-place) with a common template

static string[]
getParametersFromExpression(DOMNode $node, string $expr)

Get a list of parameters from given XPath expression

Details

at line 32
static array getParametersFromXSL(string $xsl)

Return a list of parameters in use in given XSL

Parameters

string $xsl

XSL source

Return Value

array

Alphabetically sorted list of unique parameter names

at line 73
static string highlightNode(DOMNode $node, string $prepend, string $append)

Highlight the source of a node inside of a template

Parameters

DOMNode $node

Node to highlight

string $prepend

HTML to prepend

string $append

HTML to append

Return Value

string

Template's source, as HTML

at line 128
static void replaceHomogeneousTemplates(array $templates, int $minCount = 3)

Replace simple templates (in an array, in-place) with a common template

In some situations, renderers can take advantage of multiple tags having the same template. In any configuration, there's almost always a number of "simple" tags that are rendered as an HTML element of the same name with no HTML attributes. For instance, the system tag "p" used for paragraphs, "B" tags used for "b" HTML elements, etc... This method replaces those templates with a common template that uses a dynamic element name based on the tag's name, either its nodeName or localName depending on whether the tag is namespaced, and normalized to lowercase using XPath's translate() function

Parameters

array $templates

Associative array of [tagName => template]

int $minCount

Return Value

void

at line 183
static protected string[] getParametersFromExpression(DOMNode $node, string $expr)

Get a list of parameters from given XPath expression

Parameters

DOMNode $node

Context node

string $expr

XPath expression

Return Value

string[]