# Is textilize bad?

**URL:** <https://www.ruby-forum.com/t/is-textilize-bad/76141>\
**Category:** Rails\
**Created:** [November 16, 2006, 8:25am UTC](https://www.ruby-forum.com/t/is-textilize-bad/76141 "2006-11-16T08:25:37Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ssk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@ssk](https://www.ruby-forum.com/u/ssk)\
**Post date:** [November 16, 2006, 8:25am UTC](https://www.ruby-forum.com/t/is-textilize-bad/76141/1 "2006-11-16T08:25:37Z")

</div>

Hi,

I’m reading “Beginning Ruby on Rails E-Commerce”.  
On page 398, it says:

Caution: Although textilize is a cool quick-and-dirty helper, as a rule  
of thumb, it should never be used in a production setting.

What’s wrong with textilize?  
What’s a better alternative?

Thanks.

Sam

---

<div class="post-metadata">

**Author:** ![ssk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@ssk](https://www.ruby-forum.com/u/ssk)\
**Post date:** [November 16, 2006, 9:41am UTC](https://www.ruby-forum.com/t/is-textilize-bad/76141/2 "2006-11-16T09:41:00Z")

</div>

I don’t know, since I don’t have that book. I am guessing its something  
to  
do with security. I have been using it in production since like ages and  
its  
pretty helpful rather ‘never used’.

---

<div class="post-metadata">

**Author:** ![ssk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@ssk](https://www.ruby-forum.com/u/ssk)\
**Post date:** [November 16, 2006, 1:25pm UTC](https://www.ruby-forum.com/t/is-textilize-bad/76141/3 "2006-11-16T13:25:37Z")

</div>

Problems with textilize? Thats a new one for me.

---

<div class="post-metadata">

**Author:** ![ssk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@ssk](https://www.ruby-forum.com/u/ssk)\
**Post date:** [November 16, 2006, 5:04pm UTC](https://www.ruby-forum.com/t/is-textilize-bad/76141/4 "2006-11-16T17:04:33Z")

</div>

> I’m reading “Beginning Ruby on Rails E-Commerce”.  
> On page 398, it says:
> 
> Caution: Although textilize is a cool quick-and-dirty helper, as a rule  
> of thumb, it should never be used in a production setting.
> 
> What’s wrong with textilize?  
> What’s a better alternative?

I haven’t used it myself, but textile is redcloth… and I seem to  
remember a thread awhile back (not even sure it was this group) about  
redcloth vs bluecloth and speed issues… So maybe textile is kind of  
slow?

But again, I haven’t used it, so could be completely wrong. Search  
google  
for textile/redcloth/bluecloth for more…

---

<div class="post-metadata">

**Author:** ![ssk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@ssk](https://www.ruby-forum.com/u/ssk)\
**Post date:** [November 16, 2006, 5:24pm UTC](https://www.ruby-forum.com/t/is-textilize-bad/76141/5 "2006-11-16T17:24:37Z")

</div>

Philip H. wrote:

> I haven’t used it myself, but textile is redcloth… and I seem to  
> remember a thread awhile back (not even sure it was this group) about  
> redcloth vs bluecloth and speed issues… So maybe textile is kind of  
> slow?
> 
> But again, I haven’t used it, so could be completely wrong. Search google  
> for textile/redcloth/bluecloth for more…
> 
> >

I believe in this context the authors were saying that it was bad to use  
on text on each render. You are going to want to cache your pages  
and/or textilize the text as it goes into the db so you do not get a  
large speed hit on each page render.

Matthew M.  
[blog.mattmargolis.net](http://blog.mattmargolis.net)

---

<div class="post-metadata">

**Author:** ![ssk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@ssk](https://www.ruby-forum.com/u/ssk)\
**Post date:** [November 16, 2006, 5:27pm UTC](https://www.ruby-forum.com/t/is-textilize-bad/76141/6 "2006-11-16T17:27:46Z")

</div>

Philip H. wrote:

> I haven’t used it myself, but textile is redcloth… and I seem to  
> remember a thread awhile back (not even sure it was this group) about  
> redcloth vs bluecloth and speed issues… So maybe textile is kind of  
> slow?

That rings a bell. One solution to the speed problem is to cache the  
textilized text int he database along with the original source. That way  
you only do the translation once after an edit, and the textilized  
version can be pulled from he DB when needed. This is a tactic I’d use  
for any formatting language used on a high-traffic site.

Dougal.

---

<div class="post-metadata">

**Author:** ![ssk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@ssk](https://www.ruby-forum.com/u/ssk)\
**Post date:** [November 16, 2006, 8:32pm UTC](https://www.ruby-forum.com/t/is-textilize-bad/76141/7 "2006-11-16T20:32:31Z")

</div>

Douglas S. wrote:

> That rings a bell. One solution to the speed problem is to cache the  
> textilized text int he database along with the original source. That way  
> you only do the translation once after an edit, and the textilized  
> version can be pulled from he DB when needed. This is a tactic I’d use  
> for any formatting language used on a high-traffic site.

I’d say that fragment caching is probably a simpler performance-focused  
fix, rather than creating a more convoluted model.

The big problem with textilize (and any user-generated HTML) is that  
you’re leaving your app open for cross-site-scripting attacks if you  
don’t sanitize the HTML it produces, both tags and attributes.

My schtick about safe HTML is here:

[http://www.kookdujour.com/blog/details/11](http://www.kookdujour.com/blog/details/11)

And I wrote a pretty flexible helper method to ensure safe user-created  
HTML.

-DJCP

---

<div class="post-metadata">

**Author:** ![ssk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@ssk](https://www.ruby-forum.com/u/ssk)\
**Post date:** [December 4, 2006, 10:54am UTC](https://www.ruby-forum.com/t/is-textilize-bad/76141/8 "2006-12-04T10:54:49Z")

</div>

Matthew M. wrote:

> I believe in this context the authors were saying that it was bad to use  
> on text on each render. You are going to want to cache your pages  
> and/or textilize the text as it goes into the db so you do not get a  
> large speed hit on each page render.

Bingo! The quote in the original post was part of a section called  
“Rendering Speed”.

//jarkko

–  
Jarkko L.

> **[jlaine.net](https://jlaine.net/)**
>
> Your freedom to carry a gun messes with my freedom to walk around without fear. Your freedom to “stand your ground” with force is at odds with my …

> **[Home](https://dotherightthing.com/)**
>
> do the right thing

[http://www.railsecommerce.com](http://www.railsecommerce.com)  
[http://odesign.fi](http://odesign.fi)
