Class: Jekyll::Tags::Link
Class Method Summary
collapse
Instance Method Summary
collapse
#absolute_url, #relative_url, #strip_index
Constructor Details
#initialize(tag_name, relative_path, tokens) ⇒ Link
14
15
16
17
18
|
# File 'lib/jekyll/tags/link.rb', line 14
def initialize(tag_name, relative_path, tokens)
super
@relative_path = relative_path.strip
end
|
Class Method Details
.tag_name ⇒ Object
9
10
11
|
# File 'lib/jekyll/tags/link.rb', line 9
def tag_name
name.split("::").last.downcase
end
|
Instance Method Details
#render(context) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/jekyll/tags/link.rb', line 20
def render(context)
@context = context
site = context.registers[:site]
relative_path = Liquid::Template.parse(@relative_path).render(context)
relative_path_with_leading_slash = PathManager.join("", relative_path)
site.each_site_file do |item|
return relative_url(item) if item.relative_path == relative_path
return relative_url(item) if item.relative_path == relative_path_with_leading_slash
end
raise ArgumentError, " Could not find document '\#{relative_path}' in tag '\#{self.class.tag_name}'.\n\n Make sure the document exists and the path is correct.\n MSG\nend\n"
|