class SSTemplateParser extends Parser implements TemplateParser (View source)

This is the parser for the SilverStripe template language. It gets called on a string and uses a php-peg parser to match that string against the language structure, building up the PHP code to execute that structure as it parses

The $result array that is built up as part of the parsing (see thirdparty/php-peg/README.md for more on how parsers build results) has one special member, 'php', which contains the php equivalent of that part of the template tree.

Some match rules generate alternate php, or other variations, so check the per-match documentation too.

Terms used:

Marked: A string or lookup in the template that has been explictly marked as such - lookups by prepending with "$" (like $Foo.Bar), strings by wrapping with single or double quotes ('Foo' or "Foo")

Bare: The opposite of marked. An argument that has to has it's type inferred by usage and 2.4 defaults.

Example of using a bare argument for a loop block: <% loop Foo %>

Block: One of two SS template structures. The special characters "<%" and "%>" are used to wrap the opening and (required or forbidden depending on which block exactly) closing block marks.

Open Block: An SS template block that doesn't wrap any content or have a closing end tag (in fact, a closing end tag is forbidden)

Closed Block: An SS template block that wraps content, and requires a counterpart <% end_blockname %> tag

Angle Bracket: angle brackets "<" and ">" are used to eat whitespace between template elements N: eats white space including newlines (using in legacy _t support)

Properties

protected bool $includeDebuggingComments
protected array $closedBlocks

Stores the user-supplied closed block extension rules in the form: array( 'name' => function (&$res) {} ) See SSTemplateParser::ClosedBlock_Handle_Loop for an example of what the callable should look like

protected array $openBlocks

Stores the user-supplied open block extension rules in the form: array( 'name' => function (&$res) {} ) See SSTemplateParser::OpenBlock_Handle_Base_tag for an example of what the callable should look like

protected $match_Template_typestack
protected $match_Word_typestack
protected $match_Number_typestack
protected $match_Value_typestack
protected $match_CallArguments_typestack
protected $match_Call_typestack
protected $match_LookupStep_typestack
protected $match_LastLookupStep_typestack
protected $match_Lookup_typestack
protected $match_Translate_typestack
protected $match_InjectionVariables_typestack
protected $match_Entity_typestack
protected $match_SimpleInjection_typestack
protected $match_BracketInjection_typestack
protected $match_Injection_typestack
protected $match_DollarMarkedLookup_typestack
protected $match_QuotedString_typestack
protected $match_FreeString_typestack
protected $match_Argument_typestack
protected $match_ComparisonOperator_typestack
protected $match_Comparison_typestack
protected $match_PresenceCheck_typestack
protected $match_IfArgumentPortion_typestack
protected $match_BooleanOperator_typestack
protected $match_IfArgument_typestack
protected $match_IfPart_typestack
protected $match_ElseIfPart_typestack
protected $match_ElsePart_typestack
protected $match_If_typestack
protected $match_Require_typestack
protected $match_CacheBlockArgument_typestack
protected $match_CacheBlockArguments_typestack
protected $match_CacheBlockTemplate_typestack
protected $match_UncachedBlock_typestack
protected $match_CacheRestrictedTemplate_typestack
protected $match_CacheBlock_typestack
protected $match_OldTPart_typestack
protected $match_N_typestack
protected $match_OldTTag_typestack
protected $match_OldSprintfTag_typestack
protected $match_OldI18NTag_typestack
protected $match_NamedArgument_typestack
protected $match_Include_typestack
protected $match_BlockArguments_typestack
protected $match_NotBlockTag_typestack
protected $match_ClosedBlock_typestack
protected $match_OpenBlock_typestack
protected $match_MismatchedEndBlock_typestack
protected $match_MalformedOpenTag_typestack
protected $match_MalformedCloseTag_typestack
protected $match_MalformedBlock_typestack
protected $match_Comment_typestack
protected $match_TopTemplate_typestack
protected $match_Text_typestack

Methods

public
__construct(array $closedBlocks = array(), array $openBlocks = array())

Allow the injection of new closed & open block callables

public
construct($matchrule, $name, $arguments = null)

Override the function that constructs the result arrays to also prepare a 'php' item in the array

public
setClosedBlocks(array $closedBlocks)

Set the closed blocks that the template parser should use

public
setOpenBlocks(array $openBlocks)

Set the open blocks that the template parser should use

public
addClosedBlock(string $name, callable $callable)

Add a closed block callable to allow <% name %><% end_name %> syntax

public
addOpenBlock(string $name, callable $callable)

Add a closed block callable to allow <% name %> syntax

protected
validateExtensionBlock($name, $callable, $type)

Ensures that the arguments to addOpenBlock and addClosedBlock are valid

public
match_Template($stack = array())

No description

public
Template_STR($res, $sub)

No description

public
match_Word($stack = array())

No description

public
match_Number($stack = array())

No description

public
match_Value($stack = array())

No description

public
match_CallArguments($stack = array())

No description

public
CallArguments_Argument($res, $sub)

Values are bare words in templates, but strings in PHP. We rely on PHP's type conversion to back-convert strings to numbers when needed.

public
match_Call($stack = array())

No description

public
match_LookupStep($stack = array())

No description

public
match_LastLookupStep($stack = array())

No description

public
match_Lookup($stack = array())

No description

public
Lookup__construct($res)

No description

public
Lookup_AddLookupStep($res, $sub, $method)

The basic generated PHP of LookupStep and LastLookupStep is the same, except that LookupStep calls 'obj' to get the next ViewableData in the sequence, and LastLookupStep calls different methods (XML_val, hasValue, obj) depending on the context the lookup is used in.

public
Lookup_LookupStep($res, $sub)

No description

public
Lookup_LastLookupStep($res, $sub)

No description

public
match_Translate($stack = array())

No description

public
match_InjectionVariables($stack = array())

No description

public
match_Entity($stack = array())

No description

public
Translate__construct($res)

No description

public
Translate_Entity($res, $sub)

No description

public
Translate_Default($res, $sub)

No description

public
Translate_Context($res, $sub)

No description

public
Translate_InjectionVariables($res, $sub)

No description

public
Translate__finalise($res)

No description

public
InjectionVariables__construct($res)

No description

public
InjectionVariables_InjectionName($res, $sub)

No description

public
InjectionVariables_Argument($res, $sub)

No description

public
InjectionVariables__finalise($res)

No description

public
match_SimpleInjection($stack = array())

No description

public
match_BracketInjection($stack = array())

No description

public
match_Injection($stack = array())

No description

public
Injection_STR($res, $sub)

No description

public
match_DollarMarkedLookup($stack = array())

No description

public
DollarMarkedLookup_STR($res, $sub)

No description

public
match_QuotedString($stack = array())

No description

public
match_FreeString($stack = array())

No description

public
match_Argument($stack = array())

No description

public
Argument_DollarMarkedLookup($res, $sub)

If we get a bare value, we don't know enough to determine exactly what php would be the translation, because we don't know if the position of use indicates a lookup or a string argument.

public
Argument_QuotedString($res, $sub)

No description

public
Argument_Lookup($res, $sub)

No description

public
Argument_FreeString($res, $sub)

No description

public
match_ComparisonOperator($stack = array())

No description

public
match_Comparison($stack = array())

No description

public
Comparison_Argument($res, $sub)

No description

public
Comparison_ComparisonOperator($res, $sub)

No description

public
match_PresenceCheck($stack = array())

No description

public
PresenceCheck_Not($res, $sub)

No description

public
PresenceCheck_Argument($res, $sub)

No description

public
match_IfArgumentPortion($stack = array())

No description

public
IfArgumentPortion_STR($res, $sub)

No description

public
match_BooleanOperator($stack = array())

No description

public
match_IfArgument($stack = array())

No description

public
IfArgument_IfArgumentPortion($res, $sub)

No description

public
IfArgument_BooleanOperator($res, $sub)

No description

public
match_IfPart($stack = array())

No description

public
match_ElseIfPart($stack = array())

No description

public
match_ElsePart($stack = array())

No description

public
match_If($stack = array())

No description

public
If_IfPart($res, $sub)

No description

public
If_ElseIfPart($res, $sub)

No description

public
If_ElsePart($res, $sub)

No description

public
match_Require($stack = array())

No description

public
Require_Call($res, $sub)

No description

public
match_CacheBlockArgument($stack = array())

No description

public
CacheBlockArgument_DollarMarkedLookup($res, $sub)

No description

public
CacheBlockArgument_QuotedString($res, $sub)

No description

public
CacheBlockArgument_Lookup($res, $sub)

No description

public
match_CacheBlockArguments($stack = array())

No description

public
CacheBlockArguments_CacheBlockArgument($res, $sub)

No description

public
match_CacheBlockTemplate($stack = array())

No description

public
match_UncachedBlock($stack = array())

No description

public
UncachedBlock_Template($res, $sub)

No description

public
match_CacheRestrictedTemplate($stack = array())

No description

public
CacheRestrictedTemplate_CacheBlock($res, $sub)

No description

public
CacheRestrictedTemplate_UncachedBlock($res, $sub)

No description

public
match_CacheBlock($stack = array())

No description

public
CacheBlock__construct($res)

No description

public
CacheBlock_CacheBlockArguments($res, $sub)

No description

public
CacheBlock_Condition($res, $sub)

No description

public
CacheBlock_CacheBlock($res, $sub)

No description

public
CacheBlock_UncachedBlock($res, $sub)

No description

public
CacheBlock_CacheBlockTemplate($res, $sub)

No description

public
match_OldTPart($stack = array())

No description

public
match_N($stack = array())

No description

public
OldTPart__construct($res)

No description

public
OldTPart_QuotedString($res, $sub)

No description

public
OldTPart_CallArguments($res, $sub)

No description

public
OldTPart__finalise($res)

No description

public
match_OldTTag($stack = array())

No description

public
OldTTag_OldTPart($res, $sub)

No description

public
match_OldSprintfTag($stack = array())

No description

public
OldSprintfTag__construct($res)

No description

public
OldSprintfTag_OldTPart($res, $sub)

No description

public
OldSprintfTag_CallArguments($res, $sub)

No description

public
match_OldI18NTag($stack = array())

No description

public
OldI18NTag_STR($res, $sub)

No description

public
match_NamedArgument($stack = array())

No description

public
NamedArgument_Name($res, $sub)

No description

public
NamedArgument_Value($res, $sub)

No description

public
match_Include($stack = array())

No description

public
Include__construct($res)

No description

public
Include_Template($res, $sub)

No description

public
Include_NamedArgument($res, $sub)

No description

public
Include__finalise($res)

No description

public
match_BlockArguments($stack = array())

No description

public
match_NotBlockTag($stack = array())

No description

public
match_ClosedBlock($stack = array())

No description

public
ClosedBlock__construct($res)

As mentioned in the parser comment, block handling is kept fairly generic for extensibility. The match rule builds up two important elements in the match result array: 'ArgumentCount' - how many arguments were passed in the opening tag 'Arguments' an array of the Argument match rule result arrays

public
ClosedBlock_BlockArguments($res, $sub)

No description

public
ClosedBlock__finalise($res)

No description

public
ClosedBlock_Handle_Loop($res)

This is an example of a block handler function. This one handles the loop tag.

public
ClosedBlock_Handle_Control($res) deprecated

The deprecated closed block handler for control blocks

public
ClosedBlock_Handle_With($res)

The closed block handler for with blocks

public
match_OpenBlock($stack = array())

No description

public
OpenBlock__construct($res)

No description

public
OpenBlock_BlockArguments($res, $sub)

No description

public
OpenBlock__finalise($res)

No description

public
OpenBlock_Handle_Debug($res)

This is an open block handler, for the <% debug %> utility tag

public
OpenBlock_Handle_Base_tag($res)

This is an open block handler, for the <% base_tag %> tag

public
OpenBlock_Handle_Current_page($res)

This is an open block handler, for the <% current_page %> tag

public
match_MismatchedEndBlock($stack = array())

No description

public
MismatchedEndBlock__finalise($res)

No description

public
match_MalformedOpenTag($stack = array())

No description

public
MalformedOpenTag__finalise($res)

No description

public
match_MalformedCloseTag($stack = array())

No description

public
MalformedCloseTag__finalise($res)

No description

public
match_MalformedBlock($stack = array())

No description

public
match_Comment($stack = array())

No description

public
Comment__construct($res)

No description

public
match_TopTemplate($stack = array())

No description

public
TopTemplate__construct($res)

The TopTemplate also includes the opening stanza to start off the template

public
match_Text($stack = array())

No description

public
Text__finalise($res)

We convert text

public
mixed|string
compileString($string, string $templateName = "", bool $includeDebuggingComments = false, bool $topTemplate = true)

Compiles some passed template source code into the php code that will execute as per the template source.

protected
string
includeDebuggingComments(string $code, $templateName)

No description

public static 
mixed|string
compileFile($template)

Compiles some file that contains template source code, and returns the php code that will execute as per that source

Details

__construct(array $closedBlocks = array(), array $openBlocks = array())

Allow the injection of new closed & open block callables

Parameters

array $closedBlocks
array $openBlocks

construct($matchrule, $name, $arguments = null)

Override the function that constructs the result arrays to also prepare a 'php' item in the array

Parameters

$matchrule
$name
$arguments

setClosedBlocks(array $closedBlocks)

Set the closed blocks that the template parser should use

This method will delete any existing closed blocks, please use addClosedBlock if you don't want to overwrite

Parameters

array $closedBlocks

Exceptions

InvalidArgumentException

setOpenBlocks(array $openBlocks)

Set the open blocks that the template parser should use

This method will delete any existing open blocks, please use addOpenBlock if you don't want to overwrite

Parameters

array $openBlocks

Exceptions

InvalidArgumentException

addClosedBlock(string $name, callable $callable)

Add a closed block callable to allow <% name %><% end_name %> syntax

Parameters

string $name

The name of the token to be used in the syntax <% name %><% end_name %>

callable $callable

The function that modifies the generation of template code

Exceptions

InvalidArgumentException

addOpenBlock(string $name, callable $callable)

Add a closed block callable to allow <% name %> syntax

Parameters

string $name

The name of the token to be used in the syntax <% name %>

callable $callable

The function that modifies the generation of template code

Exceptions

InvalidArgumentException

protected validateExtensionBlock($name, $callable, $type)

Ensures that the arguments to addOpenBlock and addClosedBlock are valid

Parameters

$name
$callable
$type

Exceptions

InvalidArgumentException

match_Template($stack = array())

No description

Parameters

$stack

Template_STR($res, $sub)

No description

Parameters

$res
$sub

match_Word($stack = array())

No description

Parameters

$stack

match_Number($stack = array())

No description

Parameters

$stack

match_Value($stack = array())

No description

Parameters

$stack

match_CallArguments($stack = array())

No description

Parameters

$stack

CallArguments_Argument($res, $sub)

Values are bare words in templates, but strings in PHP. We rely on PHP's type conversion to back-convert strings to numbers when needed.

Parameters

$res
$sub

match_Call($stack = array())

No description

Parameters

$stack

match_LookupStep($stack = array())

No description

Parameters

$stack

match_LastLookupStep($stack = array())

No description

Parameters

$stack

match_Lookup($stack = array())

No description

Parameters

$stack

Lookup__construct($res)

No description

Parameters

$res

Lookup_AddLookupStep($res, $sub, $method)

The basic generated PHP of LookupStep and LastLookupStep is the same, except that LookupStep calls 'obj' to get the next ViewableData in the sequence, and LastLookupStep calls different methods (XML_val, hasValue, obj) depending on the context the lookup is used in.

Parameters

$res
$sub
$method

Lookup_LookupStep($res, $sub)

No description

Parameters

$res
$sub

Lookup_LastLookupStep($res, $sub)

No description

Parameters

$res
$sub

match_Translate($stack = array())

No description

Parameters

$stack

match_InjectionVariables($stack = array())

No description

Parameters

$stack

match_Entity($stack = array())

No description

Parameters

$stack

Translate__construct($res)

No description

Parameters

$res

Translate_Entity($res, $sub)

No description

Parameters

$res
$sub

Translate_Default($res, $sub)

No description

Parameters

$res
$sub

Translate_Context($res, $sub)

No description

Parameters

$res
$sub

Translate_InjectionVariables($res, $sub)

No description

Parameters

$res
$sub

Translate__finalise($res)

No description

Parameters

$res

InjectionVariables__construct($res)

No description

Parameters

$res

InjectionVariables_InjectionName($res, $sub)

No description

Parameters

$res
$sub

InjectionVariables_Argument($res, $sub)

No description

Parameters

$res
$sub

InjectionVariables__finalise($res)

No description

Parameters

$res

match_SimpleInjection($stack = array())

No description

Parameters

$stack

match_BracketInjection($stack = array())

No description

Parameters

$stack

match_Injection($stack = array())

No description

Parameters

$stack

Injection_STR($res, $sub)

No description

Parameters

$res
$sub

match_DollarMarkedLookup($stack = array())

No description

Parameters

$stack

DollarMarkedLookup_STR($res, $sub)

No description

Parameters

$res
$sub

match_QuotedString($stack = array())

No description

Parameters

$stack

match_FreeString($stack = array())

No description

Parameters

$stack

match_Argument($stack = array())

No description

Parameters

$stack

Argument_DollarMarkedLookup($res, $sub)

If we get a bare value, we don't know enough to determine exactly what php would be the translation, because we don't know if the position of use indicates a lookup or a string argument.

Instead, we record 'ArgumentMode' as a member of this matches results node, which can be:

  • lookup if this argument was unambiguously a lookup (marked as such)
  • string is this argument was unambiguously a string (marked as such, or impossible to parse as lookup)
  • default if this argument needs to be handled as per 2.4

In the case of 'default', there is no php member of the results node, but instead 'lookup_php', which should be used by the parent if the context indicates a lookup, and 'string_php' which should be used if the context indicates a string

Parameters

$res
$sub

Argument_QuotedString($res, $sub)

No description

Parameters

$res
$sub

Argument_Lookup($res, $sub)

No description

Parameters

$res
$sub

Argument_FreeString($res, $sub)

No description

Parameters

$res
$sub

match_ComparisonOperator($stack = array())

No description

Parameters

$stack

match_Comparison($stack = array())

No description

Parameters

$stack

Comparison_Argument($res, $sub)

No description

Parameters

$res
$sub

Comparison_ComparisonOperator($res, $sub)

No description

Parameters

$res
$sub

match_PresenceCheck($stack = array())

No description

Parameters

$stack

PresenceCheck_Not($res, $sub)

No description

Parameters

$res
$sub

PresenceCheck_Argument($res, $sub)

No description

Parameters

$res
$sub

match_IfArgumentPortion($stack = array())

No description

Parameters

$stack

IfArgumentPortion_STR($res, $sub)

No description

Parameters

$res
$sub

match_BooleanOperator($stack = array())

No description

Parameters

$stack

match_IfArgument($stack = array())

No description

Parameters

$stack

IfArgument_IfArgumentPortion($res, $sub)

No description

Parameters

$res
$sub

IfArgument_BooleanOperator($res, $sub)

No description

Parameters

$res
$sub

match_IfPart($stack = array())

No description

Parameters

$stack

match_ElseIfPart($stack = array())

No description

Parameters

$stack

match_ElsePart($stack = array())

No description

Parameters

$stack

match_If($stack = array())

No description

Parameters

$stack

If_IfPart($res, $sub)

No description

Parameters

$res
$sub

If_ElseIfPart($res, $sub)

No description

Parameters

$res
$sub

If_ElsePart($res, $sub)

No description

Parameters

$res
$sub

match_Require($stack = array())

No description

Parameters

$stack

Require_Call($res, $sub)

No description

Parameters

$res
$sub

match_CacheBlockArgument($stack = array())

No description

Parameters

$stack

CacheBlockArgument_DollarMarkedLookup($res, $sub)

No description

Parameters

$res
$sub

CacheBlockArgument_QuotedString($res, $sub)

No description

Parameters

$res
$sub

CacheBlockArgument_Lookup($res, $sub)

No description

Parameters

$res
$sub

match_CacheBlockArguments($stack = array())

No description

Parameters

$stack

CacheBlockArguments_CacheBlockArgument($res, $sub)

No description

Parameters

$res
$sub

match_CacheBlockTemplate($stack = array())

No description

Parameters

$stack

match_UncachedBlock($stack = array())

No description

Parameters

$stack

UncachedBlock_Template($res, $sub)

No description

Parameters

$res
$sub

match_CacheRestrictedTemplate($stack = array())

No description

Parameters

$stack

CacheRestrictedTemplate_CacheBlock($res, $sub)

No description

Parameters

$res
$sub

CacheRestrictedTemplate_UncachedBlock($res, $sub)

No description

Parameters

$res
$sub

match_CacheBlock($stack = array())

No description

Parameters

$stack

CacheBlock__construct($res)

No description

Parameters

$res

CacheBlock_CacheBlockArguments($res, $sub)

No description

Parameters

$res
$sub

CacheBlock_Condition($res, $sub)

No description

Parameters

$res
$sub

CacheBlock_CacheBlock($res, $sub)

No description

Parameters

$res
$sub

CacheBlock_UncachedBlock($res, $sub)

No description

Parameters

$res
$sub

CacheBlock_CacheBlockTemplate($res, $sub)

No description

Parameters

$res
$sub

match_OldTPart($stack = array())

No description

Parameters

$stack

match_N($stack = array())

No description

Parameters

$stack

OldTPart__construct($res)

No description

Parameters

$res

OldTPart_QuotedString($res, $sub)

No description

Parameters

$res
$sub

OldTPart_CallArguments($res, $sub)

No description

Parameters

$res
$sub

OldTPart__finalise($res)

No description

Parameters

$res

match_OldTTag($stack = array())

No description

Parameters

$stack

OldTTag_OldTPart($res, $sub)

No description

Parameters

$res
$sub

match_OldSprintfTag($stack = array())

No description

Parameters

$stack

OldSprintfTag__construct($res)

No description

Parameters

$res

OldSprintfTag_OldTPart($res, $sub)

No description

Parameters

$res
$sub

OldSprintfTag_CallArguments($res, $sub)

No description

Parameters

$res
$sub

match_OldI18NTag($stack = array())

No description

Parameters

$stack

OldI18NTag_STR($res, $sub)

No description

Parameters

$res
$sub

match_NamedArgument($stack = array())

No description

Parameters

$stack

NamedArgument_Name($res, $sub)

No description

Parameters

$res
$sub

NamedArgument_Value($res, $sub)

No description

Parameters

$res
$sub

match_Include($stack = array())

No description

Parameters

$stack

Include__construct($res)

No description

Parameters

$res

Include_Template($res, $sub)

No description

Parameters

$res
$sub

Include_NamedArgument($res, $sub)

No description

Parameters

$res
$sub

Include__finalise($res)

No description

Parameters

$res

match_BlockArguments($stack = array())

No description

Parameters

$stack

match_NotBlockTag($stack = array())

No description

Parameters

$stack

match_ClosedBlock($stack = array())

No description

Parameters

$stack

ClosedBlock__construct($res)

As mentioned in the parser comment, block handling is kept fairly generic for extensibility. The match rule builds up two important elements in the match result array: 'ArgumentCount' - how many arguments were passed in the opening tag 'Arguments' an array of the Argument match rule result arrays

Once a block has successfully been matched against, it will then look for the actual handler, which should be on this class (either defined or extended on) as ClosedBlock_Handler_Name(&$res), where Name is the tag name, first letter captialized (i.e Control, Loop, With, etc).

This function will be called with the match rule result array as it's first argument. It should return the php result of this block as it's return value, or throw an error if incorrect arguments were passed.

Parameters

$res

ClosedBlock_BlockArguments($res, $sub)

No description

Parameters

$res
$sub

ClosedBlock__finalise($res)

No description

Parameters

$res

ClosedBlock_Handle_Loop($res)

This is an example of a block handler function. This one handles the loop tag.

Parameters

$res

ClosedBlock_Handle_Control($res) deprecated

deprecated

The deprecated closed block handler for control blocks

Parameters

$res

ClosedBlock_Handle_With($res)

The closed block handler for with blocks

Parameters

$res

match_OpenBlock($stack = array())

No description

Parameters

$stack

OpenBlock__construct($res)

No description

Parameters

$res

OpenBlock_BlockArguments($res, $sub)

No description

Parameters

$res
$sub

OpenBlock__finalise($res)

No description

Parameters

$res

OpenBlock_Handle_Debug($res)

This is an open block handler, for the <% debug %> utility tag

Parameters

$res

OpenBlock_Handle_Base_tag($res)

This is an open block handler, for the <% base_tag %> tag

Parameters

$res

OpenBlock_Handle_Current_page($res)

This is an open block handler, for the <% current_page %> tag

Parameters

$res

match_MismatchedEndBlock($stack = array())

No description

Parameters

$stack

MismatchedEndBlock__finalise($res)

No description

Parameters

$res

match_MalformedOpenTag($stack = array())

No description

Parameters

$stack

MalformedOpenTag__finalise($res)

No description

Parameters

$res

match_MalformedCloseTag($stack = array())

No description

Parameters

$stack

MalformedCloseTag__finalise($res)

No description

Parameters

$res

match_MalformedBlock($stack = array())

No description

Parameters

$stack

match_Comment($stack = array())

No description

Parameters

$stack

Comment__construct($res)

No description

Parameters

$res

match_TopTemplate($stack = array())

No description

Parameters

$stack

TopTemplate__construct($res)

The TopTemplate also includes the opening stanza to start off the template

Parameters

$res

match_Text($stack = array())

No description

Parameters

$stack

Text__finalise($res)

We convert text

Parameters

$res

mixed|string compileString($string, string $templateName = "", bool $includeDebuggingComments = false, bool $topTemplate = true)

Compiles some passed template source code into the php code that will execute as per the template source.

Parameters

$string

The source of the template

string $templateName

The name of the template, normally the filename the template source was loaded from

bool $includeDebuggingComments

True is debugging comments should be included in the output

bool $topTemplate

True if this is a top template, false if it's just a template

Return Value

mixed|string

The php that, when executed (via include or exec) will behave as per the template source

Exceptions

SSTemplateParseException

protected string includeDebuggingComments(string $code, $templateName)

No description

Parameters

string $code
$templateName

Return Value

string $code

static mixed|string compileFile($template)

Compiles some file that contains template source code, and returns the php code that will execute as per that source

Parameters

$template
  • A file path that contains template source code

Return Value

mixed|string
  • The php that, when executed (via include or exec) will behave as per the template source