Sha256: 45efe7614b837fcccbd898c0fec90b60bac11447905a7b4a5fc27f2520bab344

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

module Jekyll
  
  module Filters
    def textilize(input)
      RedCloth.new(input).to_html
    end
    
    def date_to_string(date)
      date.strftime("%d %b %Y")
    end

    def date_to_long_string(date)
      date.strftime("%d %B %Y")
    end
    
    def date_to_xmlschema(date)
      date.xmlschema
    end
    
    def xml_escape(input)
      input.gsub("&", "&amp;").gsub("<", "&lt;").gsub(">", "&gt;")
    end
    
    def number_of_words(input)
      input.split.length
    end
    
    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

    def to_month(input)
      return Date::MONTHNAMES[input.to_i]
    end

    def to_month_abbr(input)
      return Date::ABBR_MONTHNAMES[input.to_i]
    end

    def format(input, format)
      format % input
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
matflores-jekyll-0.4.2 lib/jekyll/filters.rb
matflores-jekyll-0.4.3 lib/jekyll/filters.rb