Documentation

Parser
in package

Dynamic Syntax parser

Table of Contents

CHAR_CLOSE  = '}'
CHAR_OPEN  = '{'
$fieldParser  : FieldParser
$textParser  : Bracket
$varPrefix  : string
__construct()  : mixed
Constructor.
getFieldValues()  : array<string|int, mixed>
Returns the default field values defined in the template
parse()  : self
Static helper for new instances of this class.
render()  : string
Renders the template fields to their actual values
toEditor()  : array<string|int, mixed>
Returns an array of all fields and their options.
toTwig()  : string
Returns the template with fields replaced with Twig markup
toView()  : string
Returns the template with fields replaced with the simple templating engine used by the TextParser class.
evalSimpleViewField()  : string
Processes a field type and converts it to the Simple engine.
evalTwigViewField()  : string
Processes a field type and converts it to the Twig engine.
processRepeatingTag()  : mixed
processTag()  : mixed
toViewEngine()  : string
Parses the template to a specific view engine (Twig, Simple)

Constants

CHAR_CLOSE

public mixed CHAR_CLOSE = '}'

CHAR_OPEN

public mixed CHAR_OPEN = '{'

Properties

$varPrefix

protected string $varPrefix = ''

A prefix to place before all variable references when rendering the view.

Methods

__construct()

Constructor.

public __construct([string $template = null ][, array<string|int, mixed> $options = [] ]) : mixed

Available options:

  • varPrefix: Prefix to add to every top level parameter.
  • tagPrefix: Prefix to add to all tags, in addition to tags without a prefix.
Parameters
$template : string = null

Template to parse.

$options : array<string|int, mixed> = []
Return values
mixed

getFieldValues()

Returns the default field values defined in the template

public getFieldValues() : array<string|int, mixed>
Return values
array<string|int, mixed>

parse()

Static helper for new instances of this class.

public static parse(string $template[, array<string|int, mixed> $options = [] ]) : self
Parameters
$template : string
$options : array<string|int, mixed> = []
Return values
self

render()

Renders the template fields to their actual values

public render([array<string|int, mixed> $vars = [] ][, array<string|int, mixed> $options = [] ]) : string
Parameters
$vars : array<string|int, mixed> = []
$options : array<string|int, mixed> = []
Return values
string

toEditor()

Returns an array of all fields and their options.

public toEditor() : array<string|int, mixed>
Return values
array<string|int, mixed>

toTwig()

Returns the template with fields replaced with Twig markup

public toTwig() : string
Return values
string

toView()

Returns the template with fields replaced with the simple templating engine used by the TextParser class.

public toView() : string
Return values
string

evalSimpleViewField()

Processes a field type and converts it to the Simple engine.

protected evalSimpleViewField(string $field, array<string|int, mixed> $params[, mixed $prefix = null ]) : string
Parameters
$field : string
$params : array<string|int, mixed>
$prefix : mixed = null
Return values
string

evalTwigViewField()

Processes a field type and converts it to the Twig engine.

protected evalTwigViewField(string $field, array<string|int, mixed> $params[, string $prefix = null ]) : string
Parameters
$field : string
$params : array<string|int, mixed>
$prefix : string = null
Return values
string

processRepeatingTag()

protected processRepeatingTag(mixed $engine, mixed $template, mixed $field, mixed $tagDetails) : mixed
Parameters
$engine : mixed
$template : mixed
$field : mixed
$tagDetails : mixed
Return values
mixed

processTag()

protected processTag(mixed $engine, mixed $template, mixed $field, mixed $tagString) : mixed
Parameters
$engine : mixed
$template : mixed
$field : mixed
$tagString : mixed
Return values
mixed

toViewEngine()

Parses the template to a specific view engine (Twig, Simple)

protected toViewEngine(string $engine) : string
Parameters
$engine : string
Return values
string

Search results