Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Autoload alternate template engines

#1540

This patch allows alternate template engines to be loaded without explicitly installing a plugin or requiring a gem. When an unrecognized template extension is found, it looks for a gem with that extension's name that has a rails/init.rb file. If such a gem exists, it loads the init.rb and tries again to find the template handler, which will presumably be added by the gem.

Reported by nex3 · December 9th, 2008 @ 09:23 PM

State: resolved
Milestone: none
Assigned to: josh josh
Importance: none

Activity

  1. josh
    josh
    • State changed from new to open
    • Milestone cleared.

    December 11th, 2008 @ 12:40 AM

  2. josh
    josh

    +1 I like the idea

    I was kind of worried about autoloading the gem during a request, but that would only happen if you were rendering a foreign ext outside your view path. In that case, your a loser anyway.

    Do you how much it slows the process down? Cause this is going run alot during dev mode.

    Maybe we should also have a logger output for dev mode that says "autoloading gem" or something. Or maybe not.

    Is HAML the only gem that has a rails/init.rb at the moment?

    December 11th, 2008 @ 12:54 AM

  3. nex3
    nex3

    This shouldn't slow down the process very much at all. It doesn't have any effect if all your templates have recognized extensions, and even if it does hit autoload_handler_class it's just a hash lookup to realize that the gem doesn't exist. The only time it would have degraded performance would be if someone had a template that had an extension that coincidentally matched a non-template Gem. That doesn't seem very likely, and even then it shouldn't be a noticeable slowdown.

    I was under the impression that rails/init.rb was a convention for loading gems automatically. The creating_plugins guide bundled with Rails mentions creating one, though, so there's some sort of precedent.

    December 15th, 2008 @ 06:50 PM

  4. Repository
    Repository
    • State changed from open to resolved

    (from [e8c1915416579a3840573ca2c80822d96cb31823]) Auto-load template handlers based on unmatched extensions [#1540 Autoload alternate template engines state:resolved]

    Signed-off-by: Joshua Peek josh@joshpeek.com http://github.com/rails/rails/co...

    December 15th, 2008 @ 08:50 PM

  5. Repository
    Repository

    (from [c044c079ab14487b4410874be2169ab4aa9b8a23]) Revert "Auto-load template handlers based on unmatched extensions [#1540 Autoload alternate template engines state:resolved]"

    This reverts commit e8c1915416579a3840573ca2c80822d96cb31823.

    Reasons : - ActionPack tests run very slow - Gem.searcher hanging for long time when extension is nil http://github.com/rails/rails/co...

    December 19th, 2008 @ 01:09 PM