Parser
Dynamic Syntax parser
class Winter\Storm\Parse\Syntax\Parser
Constants
| Constant | Type | Value | Description |
|---|---|---|---|
CHAR_CLOSE
|
string |
"}"
|
string
"}"
|
CHAR_OPEN
|
string |
"{"
|
string
"{"
|
Properties
protected $fieldParser : Winter\Storm\Parse\Syntax\FieldParser
Field parser instance.
protected
$template
:
string
= ""
The template content to parse.
protected $textParser : Winter\Storm\Parse\Bracket
Text parser instance.
protected
$varPrefix
:
string
= ""
A prefix to place before all variable references when rendering the view.
Methods
public
final
__construct (string $template, array $options = [])
Constructor.
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.
| Property | Type | Description |
|---|---|---|
| $template | string |
string
Template to parse. |
| $options | array |
array
|
public getFieldValues () : array
Returns the default field values defined in the template
public
static
parse (string $template, array $options = [])
: static
Static helper for new instances of this class.
| Property | Type | Description |
|---|---|---|
| $template | string |
string
|
| $options | array |
array
|
public
render (array $vars = [], array $options = [])
: string
Renders the template fields to their actual values
| Property | Type | Description |
|---|---|---|
| $vars | array |
array
|
| $options | array |
array
|
public toEditor () : array
Returns an array of all fields and their options.
public toTwig () : string
Returns the template with fields replaced with Twig markup
public toView () : string
Returns the template with fields replaced with the simple templating engine used by the TextParser class.
protected
evalSimpleViewField (string $field, array $params, $prefix = null)
: string
Processes a field type and converts it to the Simple engine.
| Property | Type | Description |
|---|---|---|
| $field | string |
string
|
| $params | array |
array
|
| $prefix | mixed |
mixed
|
protected
evalTwigViewField (string $field, array $params, string $prefix = null)
: string
Processes a field type and converts it to the Twig engine.
| Property | Type | Description |
|---|---|---|
| $field | string |
string
|
| $params | array |
array
|
| $prefix | string |
string
|
protected processRepeatingTag ($engine, $template, $field, $tagDetails)
| Property | Type | Description |
|---|---|---|
| $engine | mixed |
mixed
|
| $template | mixed |
mixed
|
| $field | mixed |
mixed
|
| $tagDetails | mixed |
mixed
|
protected processTag ($engine, $template, $field, $tagString)
| Property | Type | Description |
|---|---|---|
| $engine | mixed |
mixed
|
| $template | mixed |
mixed
|
| $field | mixed |
mixed
|
| $tagString | mixed |
mixed
|
protected toViewEngine (string $engine) : string
Parses the template to a specific view engine (Twig, Simple)
| Property | Type | Description |
|---|---|---|
| $engine | string |
string
|