Module: Jekyll::Filters

Defined in:
lib/jekyll/filters.rb

Instance Method Summary collapse

Instance Method Details

#array_to_sentence_string(array) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/jekyll/filters.rb', line 41

def array_to_sentence_string(array)
  connector = "and"
  case array.length
  when 0
    ""
  when 1
    array[0].to_s
  when 2
    "#{array[0]} #{connector} #{array[1]}"
  else
    "#{array[0...-1].join(', ')}, #{connector} #{array[-1]}"
  end
end

#cgi_escape(input) ⇒ Object



33
34
35
# File 'lib/jekyll/filters.rb', line 33

def cgi_escape(input)
  CGI::escape(input)
end

#date_to_long_string(date) ⇒ Object



17
18
19
# File 'lib/jekyll/filters.rb', line 17

def date_to_long_string(date)
  date.strftime("%d %B %Y")
end

#date_to_string(date) ⇒ Object



13
14
15
# File 'lib/jekyll/filters.rb', line 13

def date_to_string(date)
  date.strftime("%d %b %Y")
end

#date_to_utc(date) ⇒ Object



25
26
27
# File 'lib/jekyll/filters.rb', line 25

def date_to_utc(date)
  date.utc
end

#date_to_xmlschema(date) ⇒ Object



21
22
23
# File 'lib/jekyll/filters.rb', line 21

def date_to_xmlschema(date)
  date.xmlschema
end

#markdownize(input) ⇒ Object



8
9
10
11
# File 'lib/jekyll/filters.rb', line 8

def markdownize(input)
  require 'rdiscount'
  RDiscount.new(input).to_html
end

#number_of_words(input) ⇒ Object



37
38
39
# File 'lib/jekyll/filters.rb', line 37

def number_of_words(input)
  input.split.length
end

#textilize(input) ⇒ Object



4
5
6
# File 'lib/jekyll/filters.rb', line 4

def textilize(input)
  RedCloth.new(input).to_html
end

#xml_escape(input) ⇒ Object



29
30
31
# File 'lib/jekyll/filters.rb', line 29

def xml_escape(input)
  CGI.escapeHTML(input)
end