Class: Jekyll::LastModifiedAtTag
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Jekyll::LastModifiedAtTag
- Defined in:
- jekyll/_plugins/jekyll-last-modified-at.rb
Instance Method Summary collapse
-
#initialize(tag_name, format, tokens) ⇒ LastModifiedAtTag
constructor
A new instance of LastModifiedAtTag.
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, format, tokens) ⇒ LastModifiedAtTag
Returns a new instance of LastModifiedAtTag.
3 4 5 6 |
# File 'jekyll/_plugins/jekyll-last-modified-at.rb', line 3 def initialize(tag_name, format, tokens) super @format = format.empty? ? nil : format.strip end |
Instance Method Details
#render(context) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'jekyll/_plugins/jekyll-last-modified-at.rb', line 8 def render(context) site_source = context.registers[:site].source article_file = context.environments.first["page"]["path"] article_file_path = File.(article_file, site_source) unless File.exists? article_file_path raise Errno::ENOENT, "#{article_file_path} does not exist!" end last_modified_time = File.mtime(article_file_path) Time.at(last_modified_time.to_i).strftime(@format || "%d-%b-%y") end |