From a615a3cc88e5b6ae3bec29b8dfb781f3a3d36794 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Tue, 22 Mar 2011 22:59:56 -0400 Subject: [PATCH] Adding a test that uses tabs. Added a test for trailing tabs and -%} Refs #284 --- lib/Twig/Lexer.php | 4 +++- test/Twig/Tests/Fixtures/tags/trim_block.test | 12 +++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/Twig/Lexer.php b/lib/Twig/Lexer.php index 6d66e87..ef8b33d 100644 --- a/lib/Twig/Lexer.php +++ b/lib/Twig/Lexer.php @@ -183,8 +183,10 @@ class Twig_Lexer implements Twig_LexerInterface protected function lexBlock() { + $trimTag = preg_quote($this->options['tag_trim_block'][1], '/'); $endTag = preg_quote($this->options['tag_block'][1], '/'); - if (empty($this->brackets) && preg_match('/\s*'. $endTag.'/A', $this->code, $match, null, $this->cursor)) { + + if (empty($this->brackets) && preg_match('/\s*'. $trimTag . '\h*|\s*' .$endTag.'/A', $this->code, $match, null, $this->cursor)) { $this->pushToken(Twig_Token::BLOCK_END_TYPE); $this->moveCursor($match[0]); diff --git a/test/Twig/Tests/Fixtures/tags/trim_block.test b/test/Twig/Tests/Fixtures/tags/trim_block.test index de26a2c..341a281 100644 --- a/test/Twig/Tests/Fixtures/tags/trim_block.test +++ b/test/Twig/Tests/Fixtures/tags/trim_block.test @@ -6,9 +6,19 @@ Whitespace trimming on tags.
  • {{ string }}
  • {%- endif %} + + --DATA-- -return array('string' => 'a value') +return array('string' => 'a value', 'trailing' => 'trailing tabs') --EXPECT-- + + \ No newline at end of file -- 1.7.2.5