你能在渲染时让ERB正确缩进吗?

Tre*_*ott 8 html ruby-on-rails erb indentation

我有几个部分,我包括在我的Rails中application.html.erb file,但生成的HTML不保留我的缩进(格式化).我被告知第一行使用与调用相同的缩进级别进行渲染_partial.html.erb,但部分中的所有后续行都会左对齐.

这会产生类似的代码(请参阅我的定位评论):

<body>
    <div id="outer">

        <div class="contentwidth main">
            <div class="logo"> <<<<< Shouldn't be this far to the right
    <h1><a href="index.html">minimal.</a></h1>
</div><!-- end logo -->     <<<<<<< Shouldn't be way over to the left
Run Code Online (Sandbox Code Playgroud)

有没有办法更好地使用ERB修复此格式/格式化我包含的部分?或者我需要使用HAML吗?

Don*_*oby 2

关于过滤器的文档包含一个使用后过滤器在将 html 发送到浏览器之前对其进行压缩的示例。

做类似的事情,但是使用Tidy之类的东西来重新格式化并替换本示例中进行压缩的 html 可能会成功。