Module: Jekyll::Filters

Defined in:
lib/jekyll/filters.rb

Instance Method Summary collapse

Instance Method Details

#array_to_sentence_string(array) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/jekyll/filters.rb', line 38

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



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

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

#date_to_long_string(date) ⇒ Object



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

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

#date_to_string(date) ⇒ Object



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

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

#date_to_xmlschema(date) ⇒ Object



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

def date_to_xmlschema(date)
  date.xmlschema
end

#number_of_words(input) ⇒ Object



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

def number_of_words(input)
  input.split.length
end

#textilize(input) ⇒ Object



6
7
8
# File 'lib/jekyll/filters.rb', line 6

def textilize(input)
  TextileConverter.new.convert(input)
end

#uri_escape(input) ⇒ Object



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

def uri_escape(input)
  URI.escape(input)
end

#xml_escape(input) ⇒ Object



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

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