mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 23:40:45 -07:00
Expose alias_name and for_loop? in render tag
This commit is contained in:
@@ -31,7 +31,7 @@ module Liquid
|
|||||||
|
|
||||||
disable_tags "include"
|
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)
|
def initialize(tag_name, markup, options)
|
||||||
super
|
super
|
||||||
@@ -45,7 +45,7 @@ module Liquid
|
|||||||
@alias_name = Regexp.last_match(6)
|
@alias_name = Regexp.last_match(6)
|
||||||
@variable_name_expr = variable_name ? parse_expression(variable_name) : nil
|
@variable_name_expr = variable_name ? parse_expression(variable_name) : nil
|
||||||
@template_name_expr = parse_expression(template_name)
|
@template_name_expr = parse_expression(template_name)
|
||||||
@for = (with_or_for == FOR)
|
@for_loop? = (with_or_for == FOR)
|
||||||
|
|
||||||
@attributes = {}
|
@attributes = {}
|
||||||
markup.scan(TagAttributes) do |key, value|
|
markup.scan(TagAttributes) do |key, value|
|
||||||
@@ -85,7 +85,7 @@ module Liquid
|
|||||||
}
|
}
|
||||||
|
|
||||||
variable = @variable_name_expr ? context.evaluate(@variable_name_expr) : nil
|
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)
|
forloop = Liquid::ForloopDrop.new(template_name, variable.count, nil)
|
||||||
variable.each { |var| render_partial_func.call(var, forloop) }
|
variable.each { |var| render_partial_func.call(var, forloop) }
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user