class Jekyll::Cat
Public Class Methods
new(tag_name, path, tokens)
click to toggle source
Calls superclass method
# File lib/jekyll-cat.rb, line 8 def initialize(tag_name, path, tokens) super @path = path end
Public Instance Methods
render(context)
click to toggle source
# File lib/jekyll-cat.rb, line 13 def render(context) # parse what was passed to the tag, in case it was a variable if "#{context[@path]}" != "" path = "#{context[@path]}" else path = @path end # deal with the path, returning the content if path =~ URI::regexp # the requested resource is a URL return render_url(context, path) elsif path[0] == '/' # the requested resource is an file, specified with an absolute path return render_file_abs(context, path) else # the requested resource is an file, specified with a relative path return render_file_rel(context, path) end end
render_file_abs(context, path)
click to toggle source
# File lib/jekyll-cat.rb, line 34 def render_file_abs(context, path) content = File.read(path.strip) return content end
render_file_rel(context, path)
click to toggle source
# File lib/jekyll-cat.rb, line 39 def render_file_rel(context, path) site_source = context.registers[:site].config['source'] file_path = site_source + '/' + path content = File.read(file_path.strip) return content end
render_url(context, path)
click to toggle source
# File lib/jekyll-cat.rb, line 46 def render_url(context, path) encoded_url = URI.encode(path) return open(encoded_url).read end