Installing the Theme support plugin with Rails 2.1
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 :)
7 comments
Comments
-
Watch out! This doesn't work for rendering inside blocks, like: render :page do RJS thingies!
-
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.
-
@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 :)
-
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.
-
I would like to, but I have different things to do for now (preparing a trip to Australia), so it will be for later :)
-
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
-
Great I'll update the code according to it :)