mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 23:40:45 -07:00
Revert some freezes on non-literals
This commit is contained in:
+1
-1
@@ -92,7 +92,7 @@ module Liquid
|
|||||||
end
|
end
|
||||||
|
|
||||||
def block_delimiter
|
def block_delimiter
|
||||||
"end#{block_name}".freeze
|
"end#{block_name}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def block_name
|
def block_name
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ module Liquid
|
|||||||
end
|
end
|
||||||
|
|
||||||
def inspect
|
def inspect
|
||||||
"#<Condition #{[@left, @operator, @right].compact.join(' '.freeze)}>".freeze
|
"#<Condition #{[@left, @operator, @right].compact.join(' '.freeze)}>"
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@@ -94,7 +94,7 @@ module Liquid
|
|||||||
|
|
||||||
left, right = context[left], context[right]
|
left, right = context[left], context[right]
|
||||||
|
|
||||||
operation = self.class.operators[op] || raise(ArgumentError.new("Unknown operator #{op}".freeze))
|
operation = self.class.operators[op] || raise(ArgumentError.new("Unknown operator #{op}"))
|
||||||
|
|
||||||
if operation.respond_to?(:call)
|
if operation.respond_to?(:call)
|
||||||
operation.call(self, left, right)
|
operation.call(self, left, right)
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ module Liquid
|
|||||||
def add_filters(filters)
|
def add_filters(filters)
|
||||||
filters = [filters].flatten.compact
|
filters = [filters].flatten.compact
|
||||||
filters.each do |f|
|
filters.each do |f|
|
||||||
raise ArgumentError, "Expected module but got: #{f.class}".freeze unless f.is_a?(Module)
|
raise ArgumentError, "Expected module but got: #{f.class}" unless f.is_a?(Module)
|
||||||
Strainer.add_known_filter(f)
|
Strainer.add_known_filter(f)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -82,9 +82,9 @@ module Liquid
|
|||||||
|
|
||||||
case e
|
case e
|
||||||
when SyntaxError
|
when SyntaxError
|
||||||
"Liquid syntax error: #{e.message}".freeze
|
"Liquid syntax error: #{e.message}"
|
||||||
else
|
else
|
||||||
"Liquid error: #{e.message}".freeze
|
"Liquid error: #{e.message}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -51,13 +51,13 @@ module Liquid
|
|||||||
|
|
||||||
def read_template_file(template_path, context)
|
def read_template_file(template_path, context)
|
||||||
full_path = full_path(template_path)
|
full_path = full_path(template_path)
|
||||||
raise FileSystemError, "No such template '#{template_path}'".freeze unless File.exists?(full_path)
|
raise FileSystemError, "No such template '#{template_path}'" unless File.exists?(full_path)
|
||||||
|
|
||||||
File.read(full_path)
|
File.read(full_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def full_path(template_path)
|
def full_path(template_path)
|
||||||
raise FileSystemError, "Illegal template name '#{template_path}'".freeze unless template_path =~ /^[^.\/][a-zA-Z0-9_\/]+$/
|
raise FileSystemError, "Illegal template name '#{template_path}'" unless template_path =~ /^[^.\/][a-zA-Z0-9_\/]+$/
|
||||||
|
|
||||||
full_path = if template_path.include?('/'.freeze)
|
full_path = if template_path.include?('/'.freeze)
|
||||||
File.join(root, File.dirname(template_path), @pattern % File.basename(template_path))
|
File.join(root, File.dirname(template_path), @pattern % File.basename(template_path))
|
||||||
@@ -65,7 +65,7 @@ module Liquid
|
|||||||
File.join(root, @pattern % template_path)
|
File.join(root, @pattern % template_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
raise FileSystemError, "Illegal template path '#{File.expand_path(full_path)}'".freeze unless File.expand_path(full_path) =~ /^#{File.expand_path(root)}/
|
raise FileSystemError, "Illegal template path '#{File.expand_path(full_path)}'" unless File.expand_path(full_path) =~ /^#{File.expand_path(root)}/
|
||||||
|
|
||||||
full_path
|
full_path
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
class Module
|
class Module
|
||||||
|
|
||||||
def liquid_methods(*allowed_methods)
|
def liquid_methods(*allowed_methods)
|
||||||
drop_class = eval "class #{self.to_s}::LiquidDropClass < Liquid::Drop; self; end".freeze
|
drop_class = eval "class #{self.to_s}::LiquidDropClass < Liquid::Drop; self; end"
|
||||||
define_method :to_liquid do
|
define_method :to_liquid do
|
||||||
drop_class.new(self)
|
drop_class.new(self)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ module Liquid
|
|||||||
consume(:dotdot)
|
consume(:dotdot)
|
||||||
last = expression
|
last = expression
|
||||||
consume(:close_round)
|
consume(:close_round)
|
||||||
"(#{first}..#{last})".freeze
|
"(#{first}..#{last})"
|
||||||
else
|
else
|
||||||
raise SyntaxError, "#{token} is not a valid expression"
|
raise SyntaxError, "#{token} is not a valid expression"
|
||||||
end
|
end
|
||||||
@@ -70,7 +70,7 @@ module Liquid
|
|||||||
end
|
end
|
||||||
|
|
||||||
str << expression
|
str << expression
|
||||||
str.freeze
|
str
|
||||||
end
|
end
|
||||||
|
|
||||||
def variable_signature
|
def variable_signature
|
||||||
|
|||||||
Reference in New Issue
Block a user