mirror of
https://github.com/kemko/liquid.git
synced 2026-01-01 15:55:40 +03:00
Move configure options to a method
This commit is contained in:
@@ -106,16 +106,8 @@ module Liquid
|
|||||||
# Parse source code.
|
# Parse source code.
|
||||||
# Returns self for easy chaining
|
# Returns self for easy chaining
|
||||||
def parse(source, options = {})
|
def parse(source, options = {})
|
||||||
if (profiling = options[:profile])
|
parse_context = configure_options(options)
|
||||||
raise "Profiler not loaded, require 'liquid/profiler' first" unless defined?(Liquid::Profiler)
|
|
||||||
end
|
|
||||||
|
|
||||||
@options = options
|
|
||||||
@profiling = profiling
|
|
||||||
@line_numbers = options[:line_numbers] || profiling
|
|
||||||
parse_context = options.is_a?(ParseContext) ? options : ParseContext.new(options)
|
|
||||||
@root = Document.parse(tokenize(source), parse_context)
|
@root = Document.parse(tokenize(source), parse_context)
|
||||||
@warnings = parse_context.warnings
|
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -218,6 +210,19 @@ module Liquid
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def configure_options(options)
|
||||||
|
if (profiling = options[:profile])
|
||||||
|
raise "Profiler not loaded, require 'liquid/profiler' first" unless defined?(Liquid::Profiler)
|
||||||
|
end
|
||||||
|
|
||||||
|
@options = options
|
||||||
|
@profiling = profiling
|
||||||
|
@line_numbers = options[:line_numbers] || @profiling
|
||||||
|
parse_context = options.is_a?(ParseContext) ? options : ParseContext.new(options)
|
||||||
|
@warnings = parse_context.warnings
|
||||||
|
parse_context
|
||||||
|
end
|
||||||
|
|
||||||
def tokenize(source)
|
def tokenize(source)
|
||||||
Tokenizer.new(source, @line_numbers)
|
Tokenizer.new(source, @line_numbers)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user