Module: Jekyll::Filters

Defined in:
lib/jekyll/filters.rb,
lib/jekyll/custom_filters.rb

Defined Under Namespace

Modules: Basic, Custom

Instance Method Summary collapse

Instance Method Details

#array_to_sentence_string(array) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/jekyll/filters.rb', line 32

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



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

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

#date_to_long_string(date) ⇒ Object



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

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

#date_to_string(date) ⇒ Object



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

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

#date_to_xmlschema(date) ⇒ Object



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

def date_to_xmlschema(date)
  date.xmlschema
end

#number_of_words(input) ⇒ Object



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

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



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

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