# Formating @content\_for\_layout

**URL:** <https://www.ruby-forum.com/t/formating-content-for-layout/68457>\
**Category:** Rails\
**Created:** [February 15, 2006, 2:28am UTC](https://www.ruby-forum.com/t/formating-content-for-layout/68457 "2006-02-15T02:28:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Toph](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/848f3c/32.png) [@Toph](https://www.ruby-forum.com/u/Toph)\
**Post date:** [February 15, 2006, 2:28am UTC](https://www.ruby-forum.com/t/formating-content-for-layout/68457/1 "2006-02-15T02:28:31Z")

</div>

Hi all, I sent a message earlier, so forgive me if you have already  
read this (I got some cryptic message in German about how my  
e-mail was not read?). Anyway, I was just wondering if there was  
any way to format the html that is output using

\<%= @content\_for\_layout %\>

I want to use something like the PHP Beautify. I guess I could  
write my own, but I was hoping that Rails already had something  
built in. Thanks to all. Have a great day.

–  
Topher Fangio  
removed\_email\_address@domain.invalid  
[http://www.fangiotophia.com](http://www.fangiotophia.com)

Website Specialist  
Fangiotophia Designs  
(325) 660-7141

---

<div class="post-metadata">

**Author:** ![Toph](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/848f3c/32.png) [@Toph](https://www.ruby-forum.com/u/Toph)\
**Post date:** [February 15, 2006, 2:49am UTC](https://www.ruby-forum.com/t/formating-content-for-layout/68457/2 "2006-02-15T02:49:34Z")

</div>

The “content\_for\_layout” declaration simply renders a template within  
the  
layout… so… you’d probably want to just format the template in the  
first  
place ?  
Otherwise, assuming the @content\_for\_layout variable actually contains  
all  
the HTML (which I haven’t bothered to look at), you could run this  
variable  
through a method of your choice prior to rendering.

---

<div class="post-metadata">

**Author:** ![Toph](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/848f3c/32.png) [@Toph](https://www.ruby-forum.com/u/Toph)\
**Post date:** [February 15, 2006, 3:40am UTC](https://www.ruby-forum.com/t/formating-content-for-layout/68457/3 "2006-02-15T03:40:45Z")

</div>

Yes, I was hoping that Rails already had a method to make the html  
pretty  
without me having to write one. Or a library, or something. If not, all  
I really  
want is tabs and I wrote it in PHP, so I guess I could just copy the  
algorithm.  
Thanks for the repsonse =)

On 2/14/06, Dylan S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On 2/14/06, Toph [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > built in. Thanks to all. Have a great day.  
> > Rails mailing list

–  
Topher Fangio  
removed\_email\_address@domain.invalid  
[http://www.fangiotophia.com](http://www.fangiotophia.com)

Website Specialist  
Fangiotophia Designs  
(325) 660-7141

---

<div class="post-metadata">

**Author:** ![Toph](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/848f3c/32.png) [@Toph](https://www.ruby-forum.com/u/Toph)\
**Post date:** [February 15, 2006, 7:39am UTC](https://www.ruby-forum.com/t/formating-content-for-layout/68457/4 "2006-02-15T07:39:36Z")

</div>

There is a ruby interface to the tidy library. Sop you can use that  
to tidy up your html before output.

Cheers-  
-Ezra

On Feb 14, 2006, at 6:37 PM, Toph wrote:

> > within the
> > 
> > > I want to use something like the PHP Beautify. I guess I could  
> > > (325) 660-7141  
> > > [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)
> 
> Website Specialist  
> Fangiotophia Designs  
> (325) 660-7141
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

-Ezra Z.  
WebMaster  
Yakima Herald-Republic Newspaper  
removed\_email\_address@domain.invalid  
509-577-7732

---

<div class="post-metadata">

**Author:** ![Toph](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/848f3c/32.png) [@Toph](https://www.ruby-forum.com/u/Toph)\
**Post date:** [February 15, 2006, 10:01am UTC](https://www.ruby-forum.com/t/formating-content-for-layout/68457/5 "2006-02-15T10:01:33Z")

</div>

Toph wrote:

> 

I sent this earlier, but it sounds like you didn’t see any responses,  
so:

There is a ruby interface to tidy:

[http://rubyforge.org/projects/tidy/](http://rubyforge.org/projects/tidy/)

Not sure what you would need to do to hook it into a rails app.

You could also rewrite your rhtml files as rxml… at least I would  
think that building  
the page as an xml tree and then writing it out would create a nice neat  
source output.

b

---

<div class="post-metadata">

**Author:** ![Toph](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/848f3c/32.png) [@Toph](https://www.ruby-forum.com/u/Toph)\
**Post date:** [April 14, 2006, 10:25am UTC](https://www.ruby-forum.com/t/formating-content-for-layout/68457/6 "2006-04-14T10:25:37Z")

</div>

If someone is still interested on this topic:

[http://www.cosinux.org/blogs/dam/pages/rails-tidy](http://www.cosinux.org/blogs/dam/pages/rails-tidy)
