Skip to content

Instantly share code, notes, and snippets.

@tenderlove
Forked from anonymous/gist:263285
Created December 24, 2009 18: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 tenderlove/263289 to your computer and use it in GitHub Desktop.
Save tenderlove/263289 to your computer and use it in GitHub Desktop.
View:
- if favorite_comment.text.length < 45
%p= favorite_comment.text
- else
= sample_with_more(favorite_comment.text, favorite_comment.id)
Helper:
def sample_with_more(body, comment_id, html_options = {})
more_link = link_to(" &raquo;", :class => "show-more")
content_tag(:p, html_options) do
body[0..45] + more_link + content_tag(:span, body[46..-1], :style => "display:none")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment