mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-15 08:50:45 -07:00
Remove body attr_reader and initiliaze @body instance variable in parse method
This commit is contained in:
@@ -30,15 +30,14 @@ module Liquid
|
|||||||
class Doc < Block
|
class Doc < Block
|
||||||
NO_UNEXPECTED_ARGS = /\A\s*\z/
|
NO_UNEXPECTED_ARGS = /\A\s*\z/
|
||||||
|
|
||||||
attr_reader :body
|
|
||||||
|
|
||||||
def initialize(tag_name, markup, parse_context)
|
def initialize(tag_name, markup, parse_context)
|
||||||
super
|
super
|
||||||
@body = +""
|
|
||||||
ensure_valid_markup(tag_name, markup, parse_context)
|
ensure_valid_markup(tag_name, markup, parse_context)
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse(tokens)
|
def parse(tokens)
|
||||||
|
@body = +""
|
||||||
|
|
||||||
while (token = tokens.shift)
|
while (token = tokens.shift)
|
||||||
tag_name = token =~ BlockBody::FullTokenPossiblyInvalid && Regexp.last_match(2)
|
tag_name = token =~ BlockBody::FullTokenPossiblyInvalid && Regexp.last_match(2)
|
||||||
|
|
||||||
@@ -64,7 +63,7 @@ module Liquid
|
|||||||
end
|
end
|
||||||
|
|
||||||
def nodelist
|
def nodelist
|
||||||
[]
|
[@body]
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class DocTagUnitTest < Minitest::Test
|
|||||||
end
|
end
|
||||||
.visit
|
.visit
|
||||||
|
|
||||||
assert_equal(doc_content, doc_tag.body)
|
assert_equal(doc_content, doc_tag.nodelist.first.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_doc_tag_does_not_support_extra_arguments
|
def test_doc_tag_does_not_support_extra_arguments
|
||||||
@@ -132,7 +132,7 @@ class DocTagUnitTest < Minitest::Test
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_doc_tag_captures_token_before_enddoc
|
def test_doc_tag_captures_token_before_enddoc
|
||||||
template_source = "{% doc %}{{ incomplete{% enddoc %}"
|
template_source = "{% doc %}{{ incomplete{% enddoc %}"
|
||||||
|
|
||||||
doc_tag = nil
|
doc_tag = nil
|
||||||
ParseTreeVisitor
|
ParseTreeVisitor
|
||||||
@@ -142,7 +142,7 @@ class DocTagUnitTest < Minitest::Test
|
|||||||
end
|
end
|
||||||
.visit
|
.visit
|
||||||
|
|
||||||
assert_equal("{{ incomplete", doc_tag.body)
|
assert_equal("{{ incomplete", doc_tag.nodelist.first.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_doc_tag_preserves_error_line_numbers
|
def test_doc_tag_preserves_error_line_numbers
|
||||||
|
|||||||
Reference in New Issue
Block a user