-
Is there a way to strip a redcloth string of all redcloth tags? I
need to display a snippet of the text in an index page and want all
markings removed. I used RedCloth.new(‘a’).methods but didn’t find
anything appropriate. For now, I’m converting to html then stripping
tags. -
what’s the best practice in term of storing user’s redcloth-
formatted text? store in markup, and convert to html on the fly?
store in markup and html both? store in html and convert to markup
using clothred for editing?
-
I don’t know for sure, but I don’t think there is.
-
I store the text as the user typed in the database and then use
RedCloth to textilize it when rendering. It uses more CPU ticks but at
least that way I have the original comment stored. If a user wanted to
edit his or her comment I wouldn’t have to try something sloppy like
converting HTML back to markup but rather show them what they entered to
begin with. You can possibly store both the textilized text and the
original text for good measure (in case it needs to be parsed again
later on for whatever reason). I personally don’t do that because I do
a lot of modifications to the text in my helpers before and after it’s
been converted to HTML.
rubynuby wrote:
Is there a way to strip a redcloth string of all redcloth tags? I
need to display a snippet of the text in an index page and want all
markings removed. I used RedCloth.new(‘a’).methods but didn’t find
anything appropriate. For now, I’m converting to html then stripping
tags.what’s the best practice in term of storing user’s redcloth-
formatted text? store in markup, and convert to html on the fly?
store in markup and html both? store in html and convert to markup
using clothred for editing?
I add another column to my table paralleling the original column,
(i.e. body, filtered_body), and then use the before_save activerecord
callback to convert the textile content to html, and store the result
in filtered_body for display. That way it gets updated whenever you
make a change, but you aren’t doing it on every page load…
–matt
On 12/5/07, R. Elliott M. [email protected]ain.invalid wrote:
later on for whatever reason). I personally don’t do that because I do
- what’s the best practice in term of storing user’s redcloth-
formatted text? store in markup, and convert to html on the fly?
store in markup and html both? store in html and convert to markup
using clothred for editing?–
Posted via http://www.ruby-forum.com/.
–
Matt W.
Thermal Creative
http://blog.thermalcreative.com