October\Rain\Parse\Syntax\Parser

Source: ~/vendor/october/rain/src/Parse/Syntax/Parser.php

Dynamic Syntax parser

Protected properties

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 void __construct(array $options=NULL, string $template=array())

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.
Parameters
  • array $options
  • string $template - Template to parse.

public array getFieldValues()

Returns the default field values defined in the template

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

Static helper for new instances of this class.

Parameters
  • string $template
  • array $options

public string render(array $vars=array(), array $options=array())

Renders the template fields to their actual values

Parameters
  • array $vars
  • array $options

public array toEditor()

Returns an array of all fields and their options.

public string toTwig()

Returns the template with fields replaced with Twig markup

public string toView()

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

Protected methods

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

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

Parameters
  • string $field
  • array $params
  • $prefix

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

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

Parameters
  • string $field
  • array $params
  • string $prefix

protected void processRepeatingTag($engine, $template, $field, $tagDetails)
Parameters
  • $engine
  • $template
  • $field
  • $tagDetails

protected void processTag($engine, $template, $field, $tagString)
Parameters
  • $engine
  • $template
  • $field
  • $tagString

protected string toViewEngine(string $engine)

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

Parameters
  • string $engine