Add line numbers to warnings

This commit is contained in:
Tristan Hume
2014-09-05 14:12:30 +00:00
committed by Florian Weingarten
parent 3a0ee6ae91
commit 27c1019385
4 changed files with 15 additions and 2 deletions
+4 -2
View File
@@ -32,7 +32,8 @@ module Liquid
# fetch the tag from registered blocks
if tag = Template.tags[$1]
new_tag = tag.parse($1, $2, tokens, @options)
markup = token.is_a?(Token) ? token.child($2) : $2
new_tag = tag.parse($1, markup, tokens, @options)
new_tag.line_number = token.line_number if token.is_a?(Token)
@blank &&= new_tag.blank?
@nodelist << new_tag
@@ -103,7 +104,8 @@ module Liquid
def create_variable(token)
token.scan(ContentOfVariable) do |content|
return Variable.new(content.first, @options)
markup = token.is_a?(Token) ? token.child(content.first) : content.first
return Variable.new(markup, @options)
end
raise SyntaxError.new(options[:locale].t("errors.syntax.variable_termination".freeze, :token => token, :tag_end => VariableEnd.inspect))
end
+1
View File
@@ -8,6 +8,7 @@ module Liquid
begin
return strict_parse_with_error_context(markup)
rescue SyntaxError => e
e.line_number = markup.line_number if markup.is_a?(Token)
@warnings ||= []
@warnings << e
return lax_parse(markup)
+4
View File
@@ -10,5 +10,9 @@ module Liquid
def raw
"<raw>"
end
def child(string)
Token.new(string, @line_number)
end
end
end