From a1d5374faf5dd9bb49e7ff514f879e77ed12912f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 2 Mar 2015 17:53:47 +0100 Subject: [PATCH] removed obsolete raw tag --- lib/Twig/Lexer.php | 10 ++-- test/Twig/Tests/Fixtures/tags/raw/basic.test | 10 ---- .../tags/raw/mixed_usage_with_raw.test | 10 ---- .../Fixtures/tags/raw/whitespace_control.test | 56 ------------------- .../tags/verbatim/mixed_usage_with_raw.test | 10 ---- 5 files changed, 5 insertions(+), 91 deletions(-) delete mode 100644 test/Twig/Tests/Fixtures/tags/raw/basic.test delete mode 100644 test/Twig/Tests/Fixtures/tags/raw/mixed_usage_with_raw.test delete mode 100644 test/Twig/Tests/Fixtures/tags/raw/whitespace_control.test delete mode 100644 test/Twig/Tests/Fixtures/tags/verbatim/mixed_usage_with_raw.test diff --git a/lib/Twig/Lexer.php b/lib/Twig/Lexer.php index 158c13a0b..9d9c43faf 100644 --- a/lib/Twig/Lexer.php +++ b/lib/Twig/Lexer.php @@ -61,10 +61,10 @@ class Twig_Lexer $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', + 'lex_raw_data' => '/('.preg_quote($this->options['tag_block'][0].$this->options['whitespace_trim'], '/').'|'.preg_quote($this->options['tag_block'][0], '/').')\s*(?:endverbatim)\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_raw' => '/\s*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', @@ -175,7 +175,7 @@ class Twig_Lexer // raw data? if (preg_match($this->regexes['lex_block_raw'], $this->code, $match, null, $this->cursor)) { $this->moveCursor($match[0]); - $this->lexRawData($match[1]); + $this->lexRawData(); // {% line \d+ %} } elseif (preg_match($this->regexes['lex_block_line'], $this->code, $match, null, $this->cursor)) { $this->moveCursor($match[0]); @@ -285,9 +285,9 @@ class Twig_Lexer } } - protected function lexRawData($tag) + protected function lexRawData() { - if (!preg_match(str_replace('%s', $tag, $this->regexes['lex_raw_data']), $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) { + if (!preg_match($this->regexes['lex_raw_data'], $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) { throw new Twig_Error_Syntax(sprintf('Unexpected end of file: Unclosed "%s" block', $tag), $this->lineno, $this->filename); } diff --git a/test/Twig/Tests/Fixtures/tags/raw/basic.test b/test/Twig/Tests/Fixtures/tags/raw/basic.test deleted file mode 100644 index 0445e8530..000000000 --- a/test/Twig/Tests/Fixtures/tags/raw/basic.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"raw" tag ---TEMPLATE-- -{% raw %} -{{ foo }} -{% endraw %} ---DATA-- -return array() ---EXPECT-- -{{ foo }} diff --git a/test/Twig/Tests/Fixtures/tags/raw/mixed_usage_with_raw.test b/test/Twig/Tests/Fixtures/tags/raw/mixed_usage_with_raw.test deleted file mode 100644 index 2fd9fb26d..000000000 --- a/test/Twig/Tests/Fixtures/tags/raw/mixed_usage_with_raw.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"raw" tag ---TEMPLATE-- -{% raw %} -{{ foo }} -{% endverbatim %} ---DATA-- -return array() ---EXCEPTION-- -Twig_Error_Syntax: Unexpected end of file: Unclosed "raw" block in "index.twig" at line 2 diff --git a/test/Twig/Tests/Fixtures/tags/raw/whitespace_control.test b/test/Twig/Tests/Fixtures/tags/raw/whitespace_control.test deleted file mode 100644 index 352bb1876..000000000 --- a/test/Twig/Tests/Fixtures/tags/raw/whitespace_control.test +++ /dev/null @@ -1,56 +0,0 @@ ---TEST-- -"raw" tag ---TEMPLATE-- -1*** - -{%- raw %} - {{ 'bla' }} -{% endraw %} - -1*** -2*** - -{%- raw -%} - {{ 'bla' }} -{% endraw %} - -2*** -3*** - -{%- raw -%} - {{ 'bla' }} -{% endraw -%} - -3*** -4*** - -{%- raw -%} - {{ 'bla' }} -{%- endraw %} - -4*** -5*** - -{%- raw -%} - {{ 'bla' }} -{%- endraw -%} - -5*** ---DATA-- -return array() ---EXPECT-- -1*** - {{ 'bla' }} - - -1*** -2***{{ 'bla' }} - - -2*** -3***{{ 'bla' }} -3*** -4***{{ 'bla' }} - -4*** -5***{{ 'bla' }}5*** diff --git a/test/Twig/Tests/Fixtures/tags/verbatim/mixed_usage_with_raw.test b/test/Twig/Tests/Fixtures/tags/verbatim/mixed_usage_with_raw.test deleted file mode 100644 index 941dddcce..000000000 --- a/test/Twig/Tests/Fixtures/tags/verbatim/mixed_usage_with_raw.test +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -"verbatim" tag ---TEMPLATE-- -{% verbatim %} -{{ foo }} -{% endraw %} ---DATA-- -return array() ---EXCEPTION-- -Twig_Error_Syntax: Unexpected end of file: Unclosed "verbatim" block in "index.twig" at line 2