public
Description: rails helper that works just like truncate, but it respects, and produces well formed html
Clone URL: git://github.com/ianwhite/truncate_html.git
name age message
file .gitignore Thu Jun 05 09:30:34 -0700 2008 Ignoring garlic dir [ianwhite]
file CHANGELOG Sat Jan 05 11:26:20 -0800 2008 Initial import of truncate_html [ian]
file MIT-LICENSE Sat May 31 04:02:22 -0700 2008 Updated README, ignoring garlic build artifacts... [ianwhite]
file README.rdoc Thu Jun 05 09:31:24 -0700 2008 Fixed typo in README [ianwhite]
file Rakefile Sat May 31 04:02:22 -0700 2008 Updated README, ignoring garlic build artifacts... [ianwhite]
file SPECDOC Sat Jan 05 11:26:20 -0800 2008 Initial import of truncate_html [ian]
file garlic_example.rb Sat May 31 04:12:52 -0700 2008 Retargeted CI [ianwhite]
file init.rb Sat Jan 05 11:26:20 -0800 2008 Initial import of truncate_html [ian]
file install.rb Sat Jan 05 11:26:20 -0800 2008 Initial import of truncate_html [ian]
directory lib/ Sat Jun 14 06:01:48 -0700 2008 Better loading of gems [ianwhite]
directory spec/ Sat May 31 04:14:21 -0700 2008 Fixed typo [ianwhite]
README.rdoc

http://plugins.ardes.com > truncate_html

truncate_html

Ardes::TruncateHtml is just like the vanilla truncate rails helper, except it respects tags and html entities, and returns valid html.

Rexml and HtmlEntities are used for the parsing. If the input is invalid html, then hpricot is used to fix it up (but is not used when the input is fine).

Inspired and heavily influenced by http://mikeburnscoder.wordpress.com/2006/11/11/truncating-html-in-ruby/ and the links contained therein.

Dependencies

Requires the htmlentities and hpricot gems:

  gem install htmlentities
  gem install hpricot

or - in your environment.rb file (>= rails 2.1)

  config.gem "hpricot"
  config.gem "htmlentities"

Specs and Coverage

  • The SPECDOC lists the specifications
  • Coverage is 100% (C0)
  • CI: tested against all 2.x branches and stable tags

RSpec is used for testing, so the tests are in spec/ rather than test/ Do rake —tasks for more details.

Continuous Integration

garlic (at http://github.com/ianwhite/garlic) is used for CI. To run the CI suite have a look at garlic_example.rb