Extract tag name to class method

This commit is contained in:
Anatoliy Yastreb 2016-07-07 11:30:45 +03:00
parent 25bff0075c
commit ba08e17204
1 changed files with 7 additions and 3 deletions

View File

@ -1,7 +1,11 @@
module Jekyll module Jekyll
module Tags module Tags
class Link < Liquid::Tag class Link < Liquid::Tag
TAG_NAME = "link".freeze class << self
def tag_name
self.name.split("::").last.downcase
end
end
def initialize(tag_name, relative_path, tokens) def initialize(tag_name, relative_path, tokens)
super super
@ -17,7 +21,7 @@ module Jekyll
end end
raise ArgumentError, <<eos raise ArgumentError, <<eos
Could not find document '#{@relative_path}' in tag '#{TAG_NAME}'. Could not find document '#{@relative_path}' in tag '#{self.class.tag_name}'.
Make sure the document exists and the path is correct. Make sure the document exists and the path is correct.
eos eos
@ -26,4 +30,4 @@ eos
end end
end end
Liquid::Template.register_tag(Jekyll::Tags::Link::TAG_NAME, Jekyll::Tags::Link) Liquid::Template.register_tag(Jekyll::Tags::Link.tag_name, Jekyll::Tags::Link)