Module: RenderHelper

Included in:
Msgtrail::PageRenderer, Msgtrail::PartialRenderer
Defined in:
lib/msgtrail/renderers.rb

Instance Method Summary collapse

Instance Method Details

#as_rfc3339(published, updated = nil) ⇒ Object



3
4
5
6
7
8
# File 'lib/msgtrail/renderers.rb', line 3

def as_rfc3339(published, updated = nil)
  updated.nil? ? datestamp = published : datestamp = updated
  ymd = datestamp[:date].split(/\D/).map(&:to_i)
  hm  = datestamp[:time].split(/\D/).map(&:to_i)
  DateTime.new(ymd[0], ymd[1], ymd[2], hm[0], hm[1], 0, datestamp[:utc_offset]).rfc3339
end

#now_as_rfc3339Object



10
11
12
# File 'lib/msgtrail/renderers.rb', line 10

def now_as_rfc3339
  DateTime.now.rfc3339
end

#titlecase(word) ⇒ Object



14
15
16
17
# File 'lib/msgtrail/renderers.rb', line 14

def titlecase(word)
  return if word.to_s.strip.empty?
  Nice.title(word)
end

#xml_safe(str) ⇒ Object



19
20
21
# File 'lib/msgtrail/renderers.rb', line 19

def xml_safe(str)
  ERB::Util.h(str)
end