Created
July 29, 2011 00:08
-
-
Save epatel/1112862 to your computer and use it in GitHub Desktop.
100 words for jekyll feeds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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