Skip to content

indentions aren't preserved when using partials #281

Closed
mickeyren opened this Issue Feb 25, 2012 · 5 comments

3 participants

@mickeyren

I use middleman most notably because of its support of partial and layout - but it isn't preserving any of the indentions when view the source code:

http://d.pr/NN36

Any idea how to fix this or make middleman preserve indentions?

@myabc
myabc commented Feb 25, 2012

@mickeyren This is not a Middleman issue, but an issue with the template engine you're using.

If using ERB templates, then proper indentation is not possible. See also this StackOverflow article.

If you use HAML then indentation should just work.

@mickeyren
@myabc
myabc commented Feb 25, 2012

Slim is another alternative, and (arguably) prettier than HAML. It can produce nicely indented output:

Slim::Engine.set_default_options pretty: true
@tdreyno
Middleman member
tdreyno commented Feb 25, 2012

I have migrated from Haml to Slim myself, but that won't solve @mickeyren's problem.

Your best solution would probably be some kind of shell script which could hook into Middleman's after_build. This script could grab all .html and curl it through Tidy's online tool.

Nasty, I know, but Tidy support in Ruby is so completely screwed up.

I'd love to see a Tidy Rack middleware that worked everywhere. This may be a long shot, but here's an old, unwatched repo on Github for a piece of middleware that only fixes indentation:

https://github.com/logicaltext/rack-prettify

@tdreyno
Middleman member
tdreyno commented Mar 4, 2012

Closing this. Happy to merge a Rack-based solution if submitted.

@tdreyno tdreyno closed this Mar 4, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.