Sha256: b7c8cafde0c3af2399752e1b02e5e6ab90f206fbfa29b4be418e4bc3446f561d
Contents?: true
Size: 874 Bytes
Versions: 2
Compression:
Stored size: 874 Bytes
Contents
# frozen_string_literal: true module Jekyll module Podcast # Liquid tag to determine the existence of a file # Path name should be the root of the directory, without an initial slash class FileExistsTag < Liquid::Tag def initialize(tag_name, path, tokens) super @path = path end 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 end end end Liquid::Template.register_tag('file_exists', Jekyll::Podcast::FileExistsTag)
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jekyll-podcast-0.9.1 | lib/jekyll/podcast/file_exists.rb |
jekyll-podcast-0.9.0 | lib/jekyll/podcast/file_exists.rb |