diff --git a/lib/liquid/tags/echo.rb b/lib/liquid/tags/echo.rb index 1f78937..19026a0 100644 --- a/lib/liquid/tags/echo.rb +++ b/lib/liquid/tags/echo.rb @@ -12,6 +12,8 @@ module Liquid # {% echo user | link %} # class Echo < Tag + attr_reader :variable + def initialize(tag_name, markup, parse_context) super @variable = Variable.new(markup, parse_context) @@ -20,6 +22,12 @@ module Liquid def render(context) @variable.render_to_output_buffer(context, +'') end + + class ParseTreeVisitor < Liquid::ParseTreeVisitor + def children + [@node.variable] + end + end end Template.register_tag('echo', Echo) diff --git a/test/unit/parse_tree_visitor_test.rb b/test/unit/parse_tree_visitor_test.rb index 32dbcf6..2c085b3 100644 --- a/test/unit/parse_tree_visitor_test.rb +++ b/test/unit/parse_tree_visitor_test.rb @@ -26,6 +26,13 @@ class ParseTreeVisitorTest < Minitest::Test ) end + def test_echo + assert_equal( + ["test"], + visit(%({% echo test %})) + ) + end + def test_if_condition assert_equal( ["test"],