Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Lexer.php

function Lexer::lexRawData

1 call to Lexer::lexRawData()
Lexer::lexData in vendor/twig/twig/src/Lexer.php

File

vendor/twig/twig/src/Lexer.php, line 455

Class

Lexer
@author Fabien Potencier <fabien@symfony.com>

Namespace

Twig

Code

private function lexRawData() : void {
    if (!preg_match($this->regexes['lex_raw_data'], $this->code, $match, \PREG_OFFSET_CAPTURE, $this->cursor)) {
        throw new SyntaxError('Unexpected end of file: Unclosed "verbatim" block.', $this->lineno, $this->source);
    }
    $text = substr($this->code, $this->cursor, $match[0][1] - $this->cursor);
    $this->moveCursor($text . $match[0][0]);
    // trim?
    if (isset($match[1][0])) {
        if ($this->options['whitespace_trim'] === $match[1][0]) {
            // whitespace_trim detected ({%-, {{- or {#-)
            $text = rtrim($text);
        }
        else {
            // whitespace_line_trim detected ({%~, {{~ or {#~)
            // don't trim \r and \n
            $text = rtrim($text, " \t\x00\v");
        }
    }
    $this->pushToken(Token::TEXT_TYPE, $text);
}
RSS feed
Powered by Drupal