开发者

ruby on rails 3 strip html whitespace

was:

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

client should obtain: (you dont need any whi开发者_如何学编程tespace in view's output!)

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

what is rails 3 way to do this without bicycles?


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


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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜