Parser for Dynamic Syntax

Protected Properties

protected string $template

template to parse

protected October\Rain\Parse\Syntax\FieldParser $fieldParser

Field parser instance.

protected October\Rain\Parse\Bracket $textParser

Text parser instance.

protected string $varPrefix

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

Public Methods

public __construct()

public __construct(string $template = null, array $options = []): void

__construct parser, with 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.

public getFieldValues()

public getFieldValues(): array 

Returns the default field values defined in the template

public static parse()

public static parse(string $template, array $options = []): self 

Static helper for new instances of this class.

public render()

public render(array $vars = [], array $options = []): string 

Renders the template fields to their actual values

public toEditor()

public toEditor(): array 

Returns an array of all fields and their options.

public toTwig()

public toTwig(): string 

Returns the template with fields replaced with Twig markup

public toView()

public toView(): string 

toView returns the template with fields replaced with the simple template engine used by the TextParser class.

Protected Methods

protected evalSimpleViewField()

protected evalSimpleViewField(
    string $field,
    array $params,
    $prefix = null
): string 

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

protected evalTwigViewField()

protected evalTwigViewField(
    string $field,
    array $params,
    string $prefix = null
): string 

evalTwigViewField processes a field type and converts it to the Twig engine.

protected processRepeatingTag()

protected processRepeatingTag($engine, $template, $field, $tagDetails): void

protected processTag()

protected processTag($engine, $template, $field, $tagString): void

protected toViewEngine()

protected toViewEngine(string $engine): string 

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