public function Twig_Lexer::__construct in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/twig/twig/lib/Twig/Lexer.php \Twig_Lexer::__construct()
File
- vendor/
twig/ twig/ lib/ Twig/ Lexer.php, line 49
Class
- Twig_Lexer
- Lexes a template string.
Code
public function __construct(Twig_Environment $env, array $options = array()) {
$this->env = $env;
$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',
);
}