mirror of
https://github.com/kemko/liquid.git
synced 2026-01-01 15:55:40 +03:00
Add ForceEqualSignAlignment to .rubocop.yml (#1190)
* Add ForceEqualSignAlignment to .rubocop.yml * Revert ForceEqualSignAlignment cop * Update method alignment * Undo addition of whitespace to improve readability * Fix missing alignment
This commit is contained in:
committed by
Mike Angell
parent
3784020a8d
commit
e83b1e4159
@@ -892,7 +892,7 @@ Lint/FormatParameterMismatch:
|
|||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
Lint/HandleExceptions:
|
Lint/HandleExceptions:
|
||||||
Enabled: true
|
AllowComments: true
|
||||||
|
|
||||||
Lint/ImplicitStringConcatenation:
|
Lint/ImplicitStringConcatenation:
|
||||||
Description: Checks for adjacent string literals on the same line, which could
|
Description: Checks for adjacent string literals on the same line, which could
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ module Liquid
|
|||||||
@left = left
|
@left = left
|
||||||
@operator = operator
|
@operator = operator
|
||||||
@right = right
|
@right = right
|
||||||
|
|
||||||
@child_relation = nil
|
@child_relation = nil
|
||||||
@child_condition = nil
|
@child_condition = nil
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,8 +7,10 @@ module Liquid
|
|||||||
|
|
||||||
def initialize(options = {})
|
def initialize(options = {})
|
||||||
@template_options = options ? options.dup : {}
|
@template_options = options ? options.dup : {}
|
||||||
|
|
||||||
@locale = @template_options[:locale] ||= I18n.new
|
@locale = @template_options[:locale] ||= I18n.new
|
||||||
@warnings = []
|
@warnings = []
|
||||||
|
|
||||||
self.depth = 0
|
self.depth = 0
|
||||||
self.partial = false
|
self.partial = false
|
||||||
end
|
end
|
||||||
@@ -20,6 +22,7 @@ module Liquid
|
|||||||
def partial=(value)
|
def partial=(value)
|
||||||
@partial = value
|
@partial = value
|
||||||
@options = value ? partial_options : @template_options
|
@options = value ? partial_options : @template_options
|
||||||
|
|
||||||
@error_mode = @options[:error_mode] || Template.error_mode
|
@error_mode = @options[:error_mode] || Template.error_mode
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ module Liquid
|
|||||||
|
|
||||||
file_system = (context.registers[:file_system] ||= Liquid::Template.file_system)
|
file_system = (context.registers[:file_system] ||= Liquid::Template.file_system)
|
||||||
source = file_system.read_template_file(template_name)
|
source = file_system.read_template_file(template_name)
|
||||||
|
|
||||||
parse_context.partial = true
|
parse_context.partial = true
|
||||||
|
|
||||||
partial = Liquid::Template.parse(source, parse_context)
|
partial = Liquid::Template.parse(source, parse_context)
|
||||||
|
|||||||
@@ -78,9 +78,12 @@ module Liquid
|
|||||||
return if input.nil?
|
return if input.nil?
|
||||||
input_str = input.to_s
|
input_str = input.to_s
|
||||||
length = Utils.to_integer(length)
|
length = Utils.to_integer(length)
|
||||||
|
|
||||||
truncate_string_str = truncate_string.to_s
|
truncate_string_str = truncate_string.to_s
|
||||||
|
|
||||||
l = length - truncate_string_str.length
|
l = length - truncate_string_str.length
|
||||||
l = 0 if l < 0
|
l = 0 if l < 0
|
||||||
|
|
||||||
input_str.length > length ? input_str[0...l].concat(truncate_string_str) : input_str
|
input_str.length > length ? input_str[0...l].concat(truncate_string_str) : input_str
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -88,8 +91,10 @@ module Liquid
|
|||||||
return if input.nil?
|
return if input.nil?
|
||||||
wordlist = input.to_s.split
|
wordlist = input.to_s.split
|
||||||
words = Utils.to_integer(words)
|
words = Utils.to_integer(words)
|
||||||
|
|
||||||
l = words - 1
|
l = words - 1
|
||||||
l = 0 if l < 0
|
l = 0 if l < 0
|
||||||
|
|
||||||
wordlist.length > l ? wordlist[0..l].join(" ").concat(truncate_string.to_s) : input
|
wordlist.length > l ? wordlist[0..l].join(" ").concat(truncate_string.to_s) : input
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -51,8 +51,8 @@ module Liquid
|
|||||||
|
|
||||||
iteration += 1
|
iteration += 1
|
||||||
iteration = 0 if iteration >= @variables.size
|
iteration = 0 if iteration >= @variables.size
|
||||||
context.registers[:cycle][key] = iteration
|
|
||||||
|
|
||||||
|
context.registers[:cycle][key] = iteration
|
||||||
output
|
output
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -105,9 +105,11 @@ module Liquid
|
|||||||
p = Parser.new(markup)
|
p = Parser.new(markup)
|
||||||
@variable_name = p.consume(:id)
|
@variable_name = p.consume(:id)
|
||||||
raise SyntaxError, options[:locale].t("errors.syntax.for_invalid_in") unless p.id?('in')
|
raise SyntaxError, options[:locale].t("errors.syntax.for_invalid_in") unless p.id?('in')
|
||||||
|
|
||||||
collection_name = p.expression
|
collection_name = p.expression
|
||||||
@name = "#{@variable_name}-#{collection_name}"
|
|
||||||
@collection_name = Expression.parse(collection_name)
|
@collection_name = Expression.parse(collection_name)
|
||||||
|
|
||||||
|
@name = "#{@variable_name}-#{collection_name}"
|
||||||
@reversed = p.id?('reversed')
|
@reversed = p.id?('reversed')
|
||||||
|
|
||||||
while p.look(:id) && p.look(:colon, 1)
|
while p.look(:id) && p.look(:colon, 1)
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ module Liquid
|
|||||||
inner_context.template_name = template_name
|
inner_context.template_name = template_name
|
||||||
inner_context.partial = true
|
inner_context.partial = true
|
||||||
inner_context['forloop'] = forloop if forloop
|
inner_context['forloop'] = forloop if forloop
|
||||||
|
|
||||||
@attributes.each do |key, value|
|
@attributes.each do |key, value|
|
||||||
inner_context[key] = context.evaluate(value)
|
inner_context[key] = context.evaluate(value)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ module Liquid
|
|||||||
to = @attributes.key?('limit') ? from + context.evaluate(@attributes['limit']).to_i : nil
|
to = @attributes.key?('limit') ? from + context.evaluate(@attributes['limit']).to_i : nil
|
||||||
|
|
||||||
collection = Utils.slice_collection(collection, from, to)
|
collection = Utils.slice_collection(collection, from, to)
|
||||||
|
|
||||||
length = collection.length
|
length = collection.length
|
||||||
|
|
||||||
cols = context.evaluate(@attributes['cols']).to_i
|
cols = context.evaluate(@attributes['cols']).to_i
|
||||||
|
|||||||
@@ -252,6 +252,7 @@ class ErrorHandlingTest < Minitest::Test
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
Liquid::Template.file_system = TestFileSystem.new
|
Liquid::Template.file_system = TestFileSystem.new
|
||||||
|
|
||||||
template = Liquid::Template.parse("Argument error:\n{% include 'product' %}", line_numbers: true)
|
template = Liquid::Template.parse("Argument error:\n{% include 'product' %}", line_numbers: true)
|
||||||
page = template.render('errors' => ErrorDrop.new)
|
page = template.render('errors' => ErrorDrop.new)
|
||||||
ensure
|
ensure
|
||||||
|
|||||||
Reference in New Issue
Block a user