This project is archived and is in readonly mode.

#1540 ✓resolved

Autoload alternate template engines

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

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.

Comments and changes to this ticket

  • josh

    josh December 11th, 2008 @ 12:40 AM

    • State changed from “new” to “open”
    • Milestone cleared.
  • josh

    josh December 11th, 2008 @ 12:54 AM

    +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?

  • nex3

    nex3 December 15th, 2008 @ 06:50 PM

    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.

  • Repository

    Repository December 15th, 2008 @ 08:50 PM

    • State changed from “open” to “resolved”

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

    Signed-off-by: Joshua Peek

  • Repository

    Repository December 19th, 2008 @ 01:09 PM

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

    This reverts commit e8c1915416579a3840573ca2c80822d96cb31823.

    Reasons : - ActionPack tests run very slow - Gem.searcher hanging for long time when extension is nil

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>

People watching this ticket


Referenced by