Skip to content

Instantly share code, notes, and snippets.

@epatel
Created July 29, 2011 00:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save epatel/1112862 to your computer and use it in GitHub Desktop.
Save epatel/1112862 to your computer and use it in GitHub Desktop.
100 words for jekyll feeds
# Added to filters.rb
def html_truncatewords(input, words = 15, truncate_string = "...")
doc = Hpricot.parse(input)
(doc/:"text()").to_s.split[0..words].join(' ') + truncate_string
end
# Used in atom.xml
<content type="html">{{ post.content | html_truncatewords:100 | xml_escape }}</content>
# Also need to add in jekyll.rb
require 'hpricot'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment