CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Sun, 24 Aug 2025 23:44:38 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20100104105231
location: https://web.archive.org/web/20100104105231/https://github.com/hgimenez/truncate_html
server-timing: captures_list;dur=1.025477, exclusion.robots;dur=0.039442, exclusion.robots.policy;dur=0.023618, esindex;dur=0.015790, cdx.remote;dur=23.689898, LoadShardBlock;dur=703.241494, PetaboxLoader3.resolve;dur=97.098496, PetaboxLoader3.datanode;dur=542.471952
x-app-server: wwwb-app202
x-ts: 302
x-tr: 777
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=1
set-cookie: wb-p-SERVER=wwwb-app202; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Sun, 24 Aug 2025 23:44:39 GMT
content-type: text/html; charset=utf-8
x-archive-orig-server: nginx/0.7.61
x-archive-orig-date: Mon, 04 Jan 2010 10:52:30 GMT
x-archive-orig-connection: close
x-archive-orig-status: 200 OK
x-archive-orig-etag: "7def9dc2b7dd6c89599fe0170dbac9ae"
x-archive-orig-x-runtime: 138ms
x-archive-orig-content-length: 26042
x-archive-orig-cache-control: private, max-age=0, must-revalidate
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: iso-8859-1
memento-datetime: Mon, 04 Jan 2010 10:52:31 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Fri, 18 Sep 2009 06:48:56 GMT", ; rel="prev memento"; datetime="Mon, 05 Oct 2009 01:45:20 GMT", ; rel="memento"; datetime="Mon, 04 Jan 2010 10:52:31 GMT", ; rel="next memento"; datetime="Sun, 14 Feb 2010 22:17:04 GMT", ; rel="last memento"; datetime="Sun, 27 Apr 2025 03:19:12 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: 51_13_20100104072220_crawl103-c/51_13_20100104104753_crawl101.arc.gz
server-timing: captures_list;dur=0.482997, exclusion.robots;dur=0.020768, exclusion.robots.policy;dur=0.012807, esindex;dur=0.010129, cdx.remote;dur=4.273362, LoadShardBlock;dur=138.274131, PetaboxLoader3.datanode;dur=118.527411, PetaboxLoader3.resolve;dur=88.138125, load_resource;dur=131.627141
x-app-server: wwwb-app202
x-ts: 200
x-tr: 331
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
content-encoding: gzip
hgimenez's truncate_html at master - GitHub
hgimenez / truncate_html
- Source
- Commits
- Network (4)
- Issues (0)
- Downloads (6)
- Wiki (1)
- Graphs
-
Branch:
master
name | age | message | |
---|---|---|---|
![]() |
.gitignore | Fri Sep 25 18:47:24 -0700 2009 | Ignoring coverage directory [hgimenez] |
![]() |
History.txt | Loading commit data... ![]() |
|
![]() |
README.markdown | Tue Aug 25 09:00:10 -0700 2009 | Gem installation instructions, now with gemcutt... [hgimenez] |
![]() |
Rakefile | ||
![]() |
VERSION | ||
![]() |
init.rb | Fri Jul 31 07:11:24 -0700 2009 | Initial commit of plugin files [hgimenez] |
![]() |
install.rb | Fri Jul 31 07:11:24 -0700 2009 | Initial commit of plugin files [hgimenez] |
![]() |
lib/ | ||
![]() |
spec/ | ||
![]() |
tasks/ | Fri Jul 31 07:11:24 -0700 2009 | Initial commit of plugin files [hgimenez] |
![]() |
truncate_html.gemspec | ||
![]() |
uninstall.rb | Fri Jul 31 07:11:24 -0700 2009 | Initial commit of plugin files [hgimenez] |
README.markdown
TruncateHtml
truncate_html is a Rails helper plugin that cuts off a string of HTML and takes care of closing any lingering open tags. There are many possible solutions to this. This plugin does not have any dependencies, and does all it's work via regular expressions.
The API is very similar to Rails' own truncate method.
Example
some_html = '<ul><li><a href="https://whatever">This is a link</a></li></ul>'
truncate_html(some_html, :length => 5, :omission => '...(continued)')
=> <ul><li><a href="https://whatever">This is...(continued)</a></li></ul>
A few notes:
- It will truncate on a word boundary.
- The default options are:
- :length => 100
- :omission => '...'
Installation
As a gem
Add this to your config/environment.rb
:
config.gem 'truncate_html',
:source => 'https://gemcutter.org'
Then either
sudo rake gems:install
or
sudo gem install truncate_html
As a plugin:
script/plugin install git://github.com/hgimenez/truncate_html.git
Issues
Found an issue? Please report it on Github's issue tracker.
Testing
The plugin is tested using RSpec. Install it on your app if you wish to run the tests.
Copyright (c) 2009 Harold A. Giménez, released under the MIT license
This feature is coming soon. Sit tight!