jlong / serve

Serve is a small Rack-based web server and rapid prototyping framework for Web applications (specifically Rails apps). Serve is meant to be a lightweight version of the Views part of the Rails MVC. This makes Serve an ideal framework for prototyping Rails applications or creating simple websites. Serve has full support for Rails-style partials and layouts.
http://get-serve.com
Other
836 stars 90 forks source link

Serve not exporting the right DOCTYPE #73

Closed ntalbott closed 12 years ago

ntalbott commented 12 years ago

@JakeCarter in #22:

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?

Also:

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.

ntalbott commented 12 years ago

I did more research on this, and it turns out what's odd isn't that the export has the XHTML doctype, but rather that serve is giving HTML5. Long story short, you need:

!!! 5

If you want haml to spit out an HTML5 DOCTYPE. I'm going to keep this open to track fixing the issue of serve giving an HTML5 when it should be giving an XHTML, but hopefully this resolves your issue.

ntalbott commented 12 years ago

Hmmm, just realized this is in the context of haml default options. Looking at that now...

JakeCarter commented 12 years ago

On my iPhone so please forgive errors.

I believe the '!!! 5' will only output an HTML5 doctype, not output all elements in the HTML5 format.

ntalbott commented 12 years ago

Yup, I think you're right. Working on a proper fix now.

ntalbott commented 12 years ago

OK, I ended up just adding a proper way to configure templating engines in d2c17a25:

Serve::FileTypeHandler.configure(:haml, :format => :html5)

I recommend putting this in a view_helpers.rb file rather than in config.ru, since if you do the latter it won't get applied when exporting. Let me know if it works for you - thanks!

JakeCarter commented 12 years ago

Awesome! You rock. I'll check it out tomorrow morning. Thanks so much.

Jake

Sent from my iPhone

On Apr 12, 2012, at 7:20 PM, Nathaniel Talbottreply@reply.github.com wrote:

OK, I ended up just adding a proper way to configure templating engines in d2c17a25:

Serve::FileTypeHandler.configure(:haml, :format => :html5)

I recommend putting this in a view_helpers.rb file rather than in config.ru, since if you do the latter it won't get applied when exporting. Let me know if it works for you - thanks!


Reply to this email directly or view it on GitHub: https://github.com/jlong/serve/issues/73#issuecomment-5107305

JakeCarter commented 12 years ago

Tried out your fix and it works great. Thanks again.