Class: Jekyll::Podcast::FileExistsTag
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Jekyll::Podcast::FileExistsTag
- Defined in:
- lib/jekyll/podcast/file_exists.rb
Overview
Liquid tag to determine the existence of a file Path name should be the root of the directory, without an initial slash
Instance Method Summary collapse
-
#initialize(tag_name, path, tokens) ⇒ FileExistsTag
constructor
A new instance of FileExistsTag.
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, path, tokens) ⇒ FileExistsTag
Returns a new instance of FileExistsTag.
8 9 10 11 |
# File 'lib/jekyll/podcast/file_exists.rb', line 8 def initialize(tag_name, path, tokens) super @path = path end |
Instance Method Details
#render(context) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/jekyll/podcast/file_exists.rb', line 13 def render(context) # Pipe parameter through Liquid to make additional replacements possible url = Liquid::Template.parse(@path).render context # Add the site source, so that it also works with a custom one site_source = context.registers[:site].config['source'] file_path = "#{site_source}/#{url}" # Check if file exists (returns true or false) File.exist?(file_path.strip!).to_s end |