the post body contains html tags , so I cannot directly truncate
it...
I thought I could use sanitize to clean up the htl tags then truncate
but it doesn't work ...


  def write_excerpt
    sanitized_body =
ActionController::Base.helpers.sanitize(self[:body])
    self[:excerpt] =
ActionController::Base.helpers.truncate(sanitized_body, :length =>
300) unless sanitized_body.length < 300
  end

as an example I get :
"<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi
commodo, ipsum sed pharetra gravida, orci magna rhoncus neque, id
pulvinar odio lorem non turpis. Nullam sit amet enim. Donec sed tellus
eget sapien fringilla nonummy. Mauris a ante. Suspendisse quam sem,
consequat at, commodo vit..."

there is a <p> tag ... which means  that they are not stripped out ...

am I wrong  ?


-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to