module Webgen::Tag::Date
Prints out the date using a format string which will be passed to Time#strftime. Therefore you can use everything Time#strftime offers.
Public Class Methods
call(tag, body, context)
click to toggle source
Return the current date formatted as specified.
# File lib/webgen/tag/date.rb 10 def self.call(tag, body, context) 11 key = context[:config]['tag.date.mi'] 12 val = context.content_node[key] 13 14 if val && val.respond_to?(:strftime) 15 time = val 16 elsif val 17 raise Webgen::RenderError.new("Value of meta information key '#{key}' not a valid date/time", 18 "tag.date", context.dest_node, context.ref_node) 19 elsif key 20 raise Webgen::RenderError.new("No meta information key '#{key}' found", 21 "tag.date", context.dest_node, context.ref_node) 22 else 23 time = Time.now 24 end 25 time.strftime(context[:config]['tag.date.format']) 26 end