Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose alias_name and for_loop? in render tag #1615

Merged
merged 3 commits into from
Sep 8, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/liquid/tags/render.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Render < Tag

disable_tags "include"

attr_reader :template_name_expr, :variable_name_expr, :attributes
attr_reader :template_name_expr, :variable_name_expr, :attributes, :alias_name, :for_loop?

def initialize(tag_name, markup, options)
super
Expand All @@ -45,7 +45,7 @@ def initialize(tag_name, markup, options)
@alias_name = Regexp.last_match(6)
@variable_name_expr = variable_name ? parse_expression(variable_name) : nil
@template_name_expr = parse_expression(template_name)
@for = (with_or_for == FOR)
@for_loop? = (with_or_for == FOR)
Maaarcocr marked this conversation as resolved.
Show resolved Hide resolved

@attributes = {}
markup.scan(TagAttributes) do |key, value|
Expand Down Expand Up @@ -85,7 +85,7 @@ def render_tag(context, output)
}

variable = @variable_name_expr ? context.evaluate(@variable_name_expr) : nil
if @for && variable.respond_to?(:each) && variable.respond_to?(:count)
if @for_loop? && variable.respond_to?(:each) && variable.respond_to?(:count)
forloop = Liquid::ForloopDrop.new(template_name, variable.count, nil)
variable.each { |var| render_partial_func.call(var, forloop) }
else
Expand Down