mirror of
https://github.com/kemko/liquid.git
synced 2026-01-01 15:55:40 +03:00
Fix regex for matching endraw tags
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
module Liquid
|
module Liquid
|
||||||
class Raw < Block
|
class Raw < Block
|
||||||
Syntax = /\A\s*\z/
|
Syntax = /\A\s*\z/
|
||||||
FullTokenPossiblyInvalid = /\A(.*)#{TagStart}\s*(\w+)\s*(.*)?#{TagEnd}\z/om
|
EndRawTag = /\A(.*)#{TagStart}\s*endraw.*?#{TagEnd}\z/om
|
||||||
|
|
||||||
def initialize(tag_name, markup, parse_context)
|
def initialize(tag_name, markup, parse_context)
|
||||||
super
|
super
|
||||||
@@ -14,7 +14,7 @@ module Liquid
|
|||||||
def parse(tokens)
|
def parse(tokens)
|
||||||
@body = +''
|
@body = +''
|
||||||
while (token = tokens.shift)
|
while (token = tokens.shift)
|
||||||
if token =~ FullTokenPossiblyInvalid && block_delimiter == Regexp.last_match(2)
|
if token =~ EndRawTag
|
||||||
@body << Regexp.last_match(1) if Regexp.last_match(1) != ""
|
@body << Regexp.last_match(1) if Regexp.last_match(1) != ""
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ class RawTagTest < Minitest::Test
|
|||||||
|
|
||||||
def test_output_in_raw
|
def test_output_in_raw
|
||||||
assert_template_result('{{ test }}', '{% raw %}{{ test }}{% endraw %}')
|
assert_template_result('{{ test }}', '{% raw %}{{ test }}{% endraw %}')
|
||||||
|
assert_template_result('test', '{% raw %}test{% endraw{% f %}')
|
||||||
|
assert_template_result('test', '{% raw %}test{% endraw{% |f %}')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_open_tag_in_raw
|
def test_open_tag_in_raw
|
||||||
|
|||||||
Reference in New Issue
Block a user