Reindenting HTML with Embeded Ruby Code (erb)
I'm wondering if there's an existent solution to the following problem:
I have the following code:
<div>
<div>
<div><%= {:something => 'abc',
:else => 'abc',
:nice => 'ok'} %>
</div>
</div>
</div>
As you can see it's unested and hard to read. I was wondering if there's an existent tool prefe开发者_开发问答rably in ruby which could reindent the document (no modifications or validations to the source). Just reindent.
The expected result would be:
<div>
<div>
<div>
<%= {:something => 'abc',
:else => 'abc',
:nice => 'ok'} %>
</div>
</div>
</div>
Also, on a side not I want to implement this as a command on Textmate.
Implementing in Textmate? You do know about ⌘⌥[
i.e. Cmd+Alt+[
(or choose it from the application menu with Text > Indent Selection)?
It's not exactly what you try to achieve in your example, but perhaps it's close enough. This is the output when applying it on your code in Textmate:
<div>
<div>
<div><%= {:something => 'abc',
:else => 'abc',
:nice => 'ok'} %>
</div>
</div>
</div>
It works in any Textmate bundle that supports indentation.
精彩评论