Skip to content

Commit 992e15a

Browse files
committed
Add variable_name_expr to render's ParseTreeVisitor
Solves Shopify/theme-check#582 `icon` should be visited in the render tag for the following snippet: ```liquid {% assign icon = 'warning' } {% render 'icon' with icon %} ```
1 parent 1fdc577 commit 992e15a

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

History.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
### Fixes
1212
* `PartialCache` now shares snippet cache with subcontexts by default (#1553) [Chris AtLee]
1313
* Hash registers no longer leak into subcontexts as static registers (#1564) [Chris AtLee]
14+
* Fix `ParseTreeVisitor` for `with` variable expressions in `Render` tag (#1596) [CP Clermont]
1415

1516
### Changed
1617
* Liquid::Context#registers now always returns a Liquid::Registers object, though supports the most used Hash functions for compatibility (#1553)

lib/liquid/tags/render.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Render < Tag
3131

3232
disable_tags "include"
3333

34-
attr_reader :template_name_expr, :attributes
34+
attr_reader :template_name_expr, :variable_name_expr, :attributes
3535

3636
def initialize(tag_name, markup, options)
3737
super
@@ -99,6 +99,7 @@ class ParseTreeVisitor < Liquid::ParseTreeVisitor
9999
def children
100100
[
101101
@node.template_name_expr,
102+
@node.variable_name_expr,
102103
] + @node.attributes.values
103104
end
104105
end

test/unit/parse_tree_visitor_test.rb

+14
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,20 @@ def test_include_for
236236
)
237237
end
238238

239+
def test_render_with
240+
assert_equal(
241+
["test"],
242+
visit(%({% render "hai" with test %}))
243+
)
244+
end
245+
246+
def test_render_for
247+
assert_equal(
248+
["test"],
249+
visit(%({% render "hai" for test %}))
250+
)
251+
end
252+
239253
def test_preserve_tree_structure
240254
assert_equal(
241255
[[nil, [

0 commit comments

Comments
 (0)