puchu
puchu

Reputation: 3652

ruby on rails 3 strip html whitespace

was:

<table >
  <tbody   >
    <tr   >
      <td valign="..."     style="..." >
      ...  

client should obtain: (you dont need any whitespace in view's output!)

<table><tbody><tr><td valign="..." style="">...

what is rails 3 way to do this without bicycles?

Upvotes: 0

Views: 1186

Answers (2)

MBO
MBO

Reputation: 30985

If you're using HAML, you can specify option :ugly to instruct it to not indent your generated html.

More informations in documentation.

Id don't know about any setting for erb, but from my understanding, erb doesn't format your code, you format if. If you want to not indent your html, you should write it as such (or preprocess your erb templates before deploying)

Upvotes: 1

Faisal
Faisal

Reputation: 18988

This is really an aesthetic issue, and doesn't have any effect on browser rendering. If you're worried about "minimizing the page size", this would not give you any noticeable changes (and would cost you server power to cleanup the output on every single request). Enabling server gzip compression would be a far better option.

However, if you are sure you want to do this, then checkout Tidy

Upvotes: 1

Related Questions