You are here

public function Twig_Lexer::__construct in Translation template extractor 7.2

Same name and namespace in other branches
  1. 6.3 vendor/Twig/Lexer.php \Twig_Lexer::__construct()
  2. 7.3 vendor/Twig/Lexer.php \Twig_Lexer::__construct()

File

vendor/Twig/Lexer.php, line 48

Class

Twig_Lexer
Lexes a template string.

Code

public function __construct(array $options = array()) {
  $this->options = array_merge(array(
    'tag_comment' => array(
      '{#',
      '#}',
    ),
    'tag_block' => array(
      '{%',
      '%}',
    ),
    'tag_variable' => array(
      '{{',
      '}}',
    ),
    'whitespace_trim' => '-',
    'interpolation' => array(
      '#{',
      '}',
    ),
  ), $options);
  $this->regexes = array(
    'lex_var' => '/\\s*' . preg_quote($this->options['whitespace_trim'] . $this->options['tag_variable'][1], '/') . '\\s*|\\s*' . preg_quote($this->options['tag_variable'][1], '/') . '/A',
    'lex_block' => '/\\s*(?:' . preg_quote($this->options['whitespace_trim'] . $this->options['tag_block'][1], '/') . '\\s*|\\s*' . preg_quote($this->options['tag_block'][1], '/') . ')\\n?/A',
    'lex_raw_data' => '/(' . preg_quote($this->options['tag_block'][0] . $this->options['whitespace_trim'], '/') . '|' . preg_quote($this->options['tag_block'][0], '/') . ')\\s*(?:end%s)\\s*(?:' . preg_quote($this->options['whitespace_trim'] . $this->options['tag_block'][1], '/') . '\\s*|\\s*' . preg_quote($this->options['tag_block'][1], '/') . ')/s',
    'operator' => $this
      ->getOperatorRegex(),
    'lex_comment' => '/(?:' . preg_quote($this->options['whitespace_trim'], '/') . preg_quote($this->options['tag_comment'][1], '/') . '\\s*|' . preg_quote($this->options['tag_comment'][1], '/') . ')\\n?/s',
    'lex_block_raw' => '/\\s*(raw|verbatim)\\s*(?:' . preg_quote($this->options['whitespace_trim'] . $this->options['tag_block'][1], '/') . '\\s*|\\s*' . preg_quote($this->options['tag_block'][1], '/') . ')/As',
    'lex_block_line' => '/\\s*line\\s+(\\d+)\\s*' . preg_quote($this->options['tag_block'][1], '/') . '/As',
    'lex_tokens_start' => '/(' . preg_quote($this->options['tag_variable'][0], '/') . '|' . preg_quote($this->options['tag_block'][0], '/') . '|' . preg_quote($this->options['tag_comment'][0], '/') . ')(' . preg_quote($this->options['whitespace_trim'], '/') . ')?/s',
    'interpolation_start' => '/' . preg_quote($this->options['interpolation'][0], '/') . '\\s*/A',
    'interpolation_end' => '/\\s*' . preg_quote($this->options['interpolation'][1], '/') . '/A',
  );
}