Sha256: 1f973cd135cbe319376ce637b6458c451385b47816c0ad6eb1e99c0838b7122a

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 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
    
    # Returns all content before the first-encountered <hr /> tag.
    # Allows authors to mark the fold with an hr in their drafts.
    # e.g. {{ content | before_fold }}
    def before_fold(input)
      input.split("<hr").first
    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

  end  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
danski-jekyll-0.4.1 lib/jekyll/filters.rb