Rename constants
This commit is contained in:
parent
3dadc94ce4
commit
a42e57f274
|
@ -2,9 +2,9 @@ module Jekyll
|
||||||
module Tags
|
module Tags
|
||||||
class IncludeTag < Liquid::Tag
|
class IncludeTag < Liquid::Tag
|
||||||
|
|
||||||
MATCHER = /([\w-]+)\s*=\s*(?:"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|([\w\.-]+))/
|
VALID_SYNTAX = /([\w-]+)\s*=\s*(?:"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|([\w\.-]+))/
|
||||||
|
|
||||||
VALID_SYNTAX = "{% include file.ext param='value' param2='value' %}"
|
SYNTAX_EXAMPLE = "{% include file.ext param='value' param2='value' %}"
|
||||||
|
|
||||||
INCLUDES_DIR = '_includes'
|
INCLUDES_DIR = '_includes'
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ module Jekyll
|
||||||
params = {}
|
params = {}
|
||||||
markup = @params
|
markup = @params
|
||||||
|
|
||||||
while match = MATCHER.match(markup) do
|
while match = VALID_SYNTAX.match(markup) do
|
||||||
markup = markup[match.end(0)..-1]
|
markup = markup[match.end(0)..-1]
|
||||||
|
|
||||||
value = if match[2]
|
value = if match[2]
|
||||||
|
@ -50,15 +50,15 @@ Invalid syntax for include tag. File contains invalid characters or sequences:
|
||||||
|
|
||||||
Valid syntax:
|
Valid syntax:
|
||||||
|
|
||||||
#{VALID_SYNTAX}
|
#{SYNTAX_EXAMPLE}
|
||||||
|
|
||||||
eos
|
eos
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_params
|
def validate_params
|
||||||
full_matcher = Regexp.compile('\A\s*(?:' + MATCHER.to_s + '(?=\s|\z)\s*)*\z')
|
full_VALID_SYNTAX = Regexp.compile('\A\s*(?:' + VALID_SYNTAX.to_s + '(?=\s|\z)\s*)*\z')
|
||||||
unless @params =~ full_matcher
|
unless @params =~ full_VALID_SYNTAX
|
||||||
raise SyntaxError.new <<-eos
|
raise SyntaxError.new <<-eos
|
||||||
Invalid syntax for include tag:
|
Invalid syntax for include tag:
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ Invalid syntax for include tag:
|
||||||
|
|
||||||
Valid syntax:
|
Valid syntax:
|
||||||
|
|
||||||
#{VALID_SYNTAX}
|
#{SYNTAX_EXAMPLE}
|
||||||
|
|
||||||
eos
|
eos
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue