mirror of
https://github.com/kemko/liquid.git
synced 2026-01-01 15:55:40 +03:00
Add ParseTreeVisitor to Echo tag
This fixes theme-check#218, wherein variables used in echo tags are not considered used by the linter. It is because our visitor doesn't see the :variable_lookup's in the echo tag since the children array is empty. But this array is empty because it is swallowed by the @variable.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user