Closed agarzola closed 11 years ago
In case it’s relevant, I’m using Slim.
Try throwing this in your config.ru file:
# Indent html for pretty debugging and do not sort attributes (Ruby 1.8)
Slim::Engine.set_default_options :pretty => true, :sort_attrs => false
See: http://rdoc.info/github/slim-template/slim#Default_options
I’m on Ruby 1.9.2p290, so I used:
# Indent html for pretty debugging and do not sort attributes (Ruby 1.9)
Slim::Engine.set_default_options pretty: true, sort_attrs: false
but it’s still generating compact HTML. Does it make a difference where in config.ru
this line is?
I'm afraid there is probably not an easy way to change the options then. You could potentially monkey patch DynamicHandler in config.ru, but that requires a lot of Ruby fu.
That’s too bad. Thanks anyway!
I reported the issue to the slim team and it seems we were missing require 'slim'
in config.ru
right before Slim::Engine.set_default_options pretty: true, sort_attrs: false
.
Adding this line is making slim produce expanded HTML when running serve
, but not when exporting. Does serve export
use a different config file where I should add this line?
Have a look here:
https://github.com/jlong/serve/blob/master/lib/serve/export.rb#L66-L86
Export is a fairly new feature. It doesn't use the config as it probably should.
Do you think adding the above lines to the compile_view
of my local server install will do the trick?
Probably.
That did it. Thank you, jlong!
Exporting my project results in compacted html (that is, all HTML in one line at the beginning of each document) instead of expanded (that is, respecting new line characters). Is there a way to get serve to convert my templates into HTML files that aren’t compacted?