Adding a test that uses tabs.
authorMark Story <mark@mark-story.com>
Wed, 23 Mar 2011 02:59:56 +0000 (22:59 -0400)
committerMark Story <mark@mark-story.com>
Tue, 29 Mar 2011 02:12:59 +0000 (22:12 -0400)
Added a test for trailing tabs and -%}
Refs #284

lib/Twig/Lexer.php
test/Twig/Tests/Fixtures/tags/trim_block.test

index 6d66e87..ef8b33d 100644 (file)
@@ -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]);
index de26a2c..341a281 100644 (file)
@@ -6,9 +6,19 @@ Whitespace trimming on tags.
         <li>{{ string }}</li>
     {%- endif %}
     </ul>
+
+       <ul>
+       {%- if trailing -%}     
+               <li>{{ trailing }}</li>
+       {%- endif -%}   
+       </ul>
 --DATA--
-return array('string' => 'a value')
+return array('string' => 'a value', 'trailing' => 'trailing tabs')
 --EXPECT--
     <ul>
         <li>a value</li>
     </ul>
+
+       <ul>
+               <li>trailing tabs</li>
+       </ul>
\ No newline at end of file