Skip to content

Instantly share code, notes, and snippets.

@davidpaulsson
Forked from blakesmith/render_time.rb
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save davidpaulsson/9806291 to your computer and use it in GitHub Desktop.
Save davidpaulsson/9806291 to your computer and use it in GitHub Desktop.
Displays the time a Jekyll page was generated in format "Month DD, YYYY"
# An example Jekyll Liquid tag. Utilizes the new plugin system.
#
# 1. Make a _plugins directory in your jekyll site, and put this class in a file there.
# 2. In anyone of your pages, you can use the 'render_time' liquid tag like so:
# {% render_time Page generated at: %}
module Jekyll
class RenderTimeTag < Liquid::Tag
def initialize(tag_name, text, tokens)
super
@text = text
end
def render(context)
"#{@text} #{Time.now.strftime("%B %d, %Y")}"
end
end
end
Liquid::Template.register_tag('render_time', Jekyll::RenderTimeTag)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment