mirror of
https://github.com/kemko/liquid.git
synced 2026-01-02 08:15:41 +03:00
Compare commits
2 Commits
sfr-verifi
...
experiment
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f439f73ba | ||
|
|
5face68cc8 |
@@ -1,11 +1,15 @@
|
||||
language: ruby
|
||||
cache: bundler
|
||||
os: [osx, linux]
|
||||
|
||||
rvm:
|
||||
- 2.4
|
||||
- 2.5
|
||||
- &latest_ruby 2.6
|
||||
- 2.7
|
||||
- 2.7.0-preview1
|
||||
- 2.7.0-preview2
|
||||
- 2.7.0-preview3
|
||||
- ruby-head
|
||||
|
||||
matrix:
|
||||
@@ -15,6 +19,9 @@ matrix:
|
||||
name: Profiling Memory Usage
|
||||
allow_failures:
|
||||
- rvm: ruby-head
|
||||
- rvm: 2.7
|
||||
- rvm: 2.7.0-preview2
|
||||
- rvm: 2.7.0-preview3
|
||||
|
||||
branches:
|
||||
only:
|
||||
|
||||
@@ -50,7 +50,19 @@ module Liquid
|
||||
template_name = context.evaluate(@template_name_expr)
|
||||
raise ArgumentError, options[:locale].t("errors.argument.include") unless template_name
|
||||
|
||||
partial = load_partial(template_name, context, parse_context)
|
||||
partial = PartialCache.load(
|
||||
template_name,
|
||||
context: context,
|
||||
parse_context: parse_context
|
||||
)
|
||||
|
||||
context_variable_name = @alias_name || template_name.split('/').last
|
||||
|
||||
variable = if @variable_name_expr
|
||||
context.evaluate(@variable_name_expr)
|
||||
else
|
||||
context.find_variable(template_name, raise_on_not_found: false)
|
||||
end
|
||||
|
||||
old_template_name = context.template_name
|
||||
old_partial = context.partial
|
||||
@@ -59,15 +71,7 @@ module Liquid
|
||||
context.partial = true
|
||||
context.stack do
|
||||
@attributes.each do |key, value|
|
||||
context[key] = evaluate(context, value)
|
||||
end
|
||||
|
||||
context_variable_name = @alias_name || template_name.split('/').last
|
||||
|
||||
variable = if @variable_name_expr
|
||||
evaluate(context, @variable_name_expr)
|
||||
else
|
||||
find_variable(context, template_name, raise_on_not_found: false)
|
||||
context[key] = context.evaluate(value)
|
||||
end
|
||||
|
||||
if variable.is_a?(Array)
|
||||
@@ -99,24 +103,6 @@ module Liquid
|
||||
] + @node.attributes.values
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def evaluate(context, value)
|
||||
context.evaluate(value)
|
||||
end
|
||||
|
||||
def find_variable(context, *args)
|
||||
context.find_variable(*args)
|
||||
end
|
||||
|
||||
def load_partial(template_name, context, parse_context)
|
||||
PartialCache.load(
|
||||
template_name,
|
||||
context: context,
|
||||
parse_context: parse_context
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
Template.register_tag('include', Include)
|
||||
|
||||
@@ -38,7 +38,11 @@ module Liquid
|
||||
template_name = context.evaluate(@template_name_expr)
|
||||
raise ArgumentError, options[:locale].t("errors.argument.include") unless template_name
|
||||
|
||||
partial = load_partial(template_name, context, parse_context)
|
||||
partial = PartialCache.load(
|
||||
template_name,
|
||||
context: context,
|
||||
parse_context: parse_context
|
||||
)
|
||||
|
||||
context_variable_name = @alias_name || template_name.split('/').last
|
||||
|
||||
@@ -49,14 +53,14 @@ module Liquid
|
||||
inner_context['forloop'] = forloop if forloop
|
||||
|
||||
@attributes.each do |key, value|
|
||||
inner_context[key] = evaluate(context, value)
|
||||
inner_context[key] = context.evaluate(value)
|
||||
end
|
||||
inner_context[context_variable_name] = var unless var.nil?
|
||||
partial.render_to_output_buffer(inner_context, output)
|
||||
forloop&.send(:increment!)
|
||||
}
|
||||
|
||||
variable = @variable_name_expr ? evaluate(context, @variable_name_expr) : nil
|
||||
variable = @variable_name_expr ? context.evaluate(@variable_name_expr) : nil
|
||||
if @for && 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) }
|
||||
@@ -74,20 +78,6 @@ module Liquid
|
||||
] + @node.attributes.values
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def evaluate(context, value)
|
||||
context.evaluate(value)
|
||||
end
|
||||
|
||||
def load_partial(template_name, context, parse_context)
|
||||
PartialCache.load(
|
||||
template_name,
|
||||
context: context,
|
||||
parse_context: parse_context
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
Template.register_tag('render', Render)
|
||||
|
||||
Reference in New Issue
Block a user