mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 15:30:39 -07:00
Pass options to include tags
This commit is contained in:
@@ -69,7 +69,7 @@ module Liquid
|
||||
return cached
|
||||
end
|
||||
source = read_template_from_file_system(context)
|
||||
partial = Liquid::Template.parse(source)
|
||||
partial = Liquid::Template.parse(source, pass_options)
|
||||
cached_partials[template_name] = partial
|
||||
context.registers[:cached_partials] = cached_partials
|
||||
partial
|
||||
@@ -88,6 +88,16 @@ module Liquid
|
||||
raise ArgumentError, "file_system.read_template_file expects two parameters: (template_name, context)"
|
||||
end
|
||||
end
|
||||
|
||||
def pass_options
|
||||
dont_pass = @options[:include_options_blacklist]
|
||||
return {locale: @options[:locale]} if dont_pass == true
|
||||
opts = @options.merge(included: true, include_options_blacklist: false)
|
||||
if dont_pass.is_a?(Array)
|
||||
dont_pass.each {|o| opts.delete(o)}
|
||||
end
|
||||
opts
|
||||
end
|
||||
end
|
||||
|
||||
Template.register_tag('include'.freeze, Include)
|
||||
|
||||
@@ -103,7 +103,8 @@ module Liquid
|
||||
# Parse source code.
|
||||
# Returns self for easy chaining
|
||||
def parse(source, options = {})
|
||||
@profiling = options.delete(:profile)
|
||||
@options = options
|
||||
@profiling = options[:profile]
|
||||
@root = Document.parse(tokenize(source), DEFAULT_OPTIONS.merge(options))
|
||||
@warnings = nil
|
||||
self
|
||||
@@ -234,7 +235,7 @@ module Liquid
|
||||
end
|
||||
|
||||
def with_profiling
|
||||
if @profiling
|
||||
if @profiling && !@options[:included]
|
||||
@profiler = Profiler.new
|
||||
@profiler.start
|
||||
|
||||
|
||||
Reference in New Issue
Block a user