Installing the Theme support plugin with Rails 2.1

written by damien on June 16th, 2008 @ 12:00 PM

Terry Heath wrote an article and more importantly a patch for the rails theme plugin.

This patch fixes the render_file method to make it work with Rails 2.1 (updated 12th august 2008) :

def render_file(template_path, use_full_path = false, local_assigns = {})
  search_path = [
    "#{RAILS_ROOT}/themes/#{controller.current_theme}/views",       # for components
    "#{RAILS_ROOT}/themes/#{controller.current_theme}",             # for layouts
  ]

  @finder.prepend_view_path(search_path)
  local_assigns['active_theme'] = get_current_theme(local_assigns)
  theme_support_old_render_file(template_path, use_full_path, local_assigns)
        
end

Enjoy :)

Comments

  • joost on 21 Jun 13:34

    Watch out! This doesn't work for rendering inside blocks, like: render :page do RJS thingies!
  • Chris on 09 Jul 22:50

    Just out of curiosity - is the color theme you use in your code examples availible in some way? preferably for VIM? That would be awesome.
  • Damien on 21 Jul 19:44

    @joost: thanks for the warn :) I've not tested that code yet cause our applications still use rails 2.0 @chris: hum the theme for the code is a theme from a javascript I've adapted... but if you want a good VIM theme I can advise you is ir_black (it's the one I use). It's based on a textmate theme, you can find it following this link: http://blog.infinitered.com/entries/show/8 Enjoy :)
  • nerb on 04 Aug 19:28

    Any interest in making this an plugin on github? with the tracker and whatnot available, i think we could do some heavy damage for years to come with this plugin. At the very least it's a good place to stick your previous code, which i've used on a new project that needed this very thing (user allowable theme selection). We could add better starting css files and support for rcss or something. thoughts? i think github is free for open source projects too.
  • Damien Le Berrigaud on 04 Aug 19:58

    I would like to, but I have different things to do for now (preparing a trip to Australia), so it will be for later :)
  • terry on 12 Aug 19:02

    I got a lot of feedback on this one, and a guy in my comments cleaned up the code a lot. I think it works for render blocks now. Thanks! Terry
  • Damien on 12 Aug 21:25

    Great I'll update the code according to it :)

Post a comment

Options:

Size

Colors