From 650d0f2948037c1053e295c2b2af0938bf805213 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sat, 2 Apr 2011 10:11:44 -0400 Subject: [PATCH] Moving newline trimming into the regexp used to match end of tags. --- lib/Twig/Lexer.php | 8 +------- 1 files changed, 1 insertions(+), 7 deletions(-) diff --git a/lib/Twig/Lexer.php b/lib/Twig/Lexer.php index 0664e8d..8df2324 100644 --- a/lib/Twig/Lexer.php +++ b/lib/Twig/Lexer.php @@ -179,16 +179,10 @@ class Twig_Lexer implements Twig_LexerInterface $trimTag = preg_quote($this->options['whitespace_trim'] . $this->options['tag_block'][1], '/'); $endTag = preg_quote($this->options['tag_block'][1], '/'); - if (empty($this->brackets) && preg_match('/\s*' . $trimTag . '\h*|\s*' . $endTag . '/A', $this->code, $match, null, $this->cursor)) { + if (empty($this->brackets) && preg_match('/\s*(' . $trimTag . '\h*|\s*' . $endTag . ')\n?/A', $this->code, $match, null, $this->cursor)) { $this->pushToken(Twig_Token::BLOCK_END_TYPE); $this->moveCursor($match[0]); $this->state = self::STATE_DATA; - - // mimics the behavior of PHP by removing the newline that follows instructions if present - if ("\n" === substr($this->code, $this->cursor, 1)) { - ++$this->cursor; - ++$this->lineno; - } } else { $this->lexExpression(); -- 1.7.2.5