Closed inferno closed 12 years ago
I've wanted to do this as well. Specifically to set my views to render with HTML5 and set the default attribute wrapper. For example:
# Default is an empty hash
# http://haml-lang.com/docs/yardoc/file.HAML_REFERENCE.html#options
configuration.haml_options = {
:format => :html5,
:attr_wrapper => '"'
}
Drop this in your config.ru:
require 'haml'
class Haml::Engine
alias old_initialize initialize
def initialize(lines, options)
options.update(:format => :html5)
old_initialize(lines, options)
end
end
I will look at making this a little cleaner for the next version.
Thank, its really helpful.
Works for me for now. Thanks John ;)
Is the above code snippet still the work-around for making this work? I dropped it in my config.ru and it didn't change the output of my HTML. Any suggestions?
Hrrm. It may require an older version of Haml. Are you using the latest alpha?
I didn't do anything special to install these. I'm running Haml 3.1.4 (Separated Sally) and Serve 1.5.1. Here's my config.ru file. Perhaps I put the snippet in the wrong place? https://gist.github.com/1994453
Ok, I found a problem with my previous config.ru script and have fixed it. Serve is now outputting my Haml as HTML5 when using the Serve server. But when I do a serve export, its still outputting XHTML 1.0 Transitional. Is there a work around for this?
That's really odd, since the export is supposed to just load those pages and dump them verbatim. Can you give me a little sample project that reproduces the issue?
Yeah. I'll test it again tonight and post a link here later. Thanks.
Ok, I created a test project here: https://github.com/JakeCarter/html5test
When I use serve
to serve the project it will render them as HTML5, but when I use serve export
it will render them as XHTML 1.0 Transitional.
Let me know if you need any more info.
Thanks for looking into this for me.
I just added a nicer way of configuring templating engines:
Serve::FileTypeHandler.configure(:haml, :format => :html5)
I'd recommend putting it in view_helpers.rb
rather than config.ru, as the latter is not loaded when exporting.
Hi!
How i can set Haml options for render templates?