Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Ruby
JavaScript

Cannot retrieve the latest commit at this time.
Failed to load latest commit information. | |||
![]() |
lib | ||
![]() |
spec | ||
![]() |
tasks | ||
![]() |
.gitignore | ||
![]() |
MIT-LICENSE | ||
![]() |
README | ||
![]() |
init.rb | ||
![]() |
install.rb | ||
![]() |
uninstall.rb |
README
CheapThemes =========== This plugin provides easy view themes support and customizable controller actions for Rails applications. Please see rails2 branch for version you can use with Rails 2.x. Installation ------------ First, grab a copy of plugin from repository: ./script/plugin install git://github.com/hubertlepicki/cheap-themes.git Usage ----- ### Theming views To allow theming of views, include following line in your controller: class ExampleController has_themable_views :find_view_theme .... end and define "find_view_theme" method in the same controller or any of parent ones that returns a String which is a theme name: class ExampleController has_themable_views :find_view_theme .... private def find_view_theme "green" end end Of course, instead of "find_view_theme" you can use your own name. Now, if you want to customize index.html.erb view file, create file "RAILS_ROOT/themes/green/views/example/index.html.erb". It's content will be used instead of standard "RAILS_ROOT/app/views/example/index.html.erb". This also works with layouts, so if you want to customize "default.html.erb" layout, just create file "RAILS_ROOT/themes/green/views/layouts/default.html.erb". ### Customizing actions If you want to customize ExampleController::index action, create file "RAILS_ROOT"/themes/green/controllers/example/index.rb" with customized code, for example: render :text => "This is customized action" And add in your controller: class ExampleController has_customizable_actions :find_action_theme .... private def find_action_theme "green" end end General notes ------------- Of course you can have multiple multiple themes. In development mode, customized controller actions are reloaded on every request. In production mode, customized controller actions are loaded only once (at first request) and then cached methods are used. Bugs and requests ================= Please use Github to fork and submit merge requests or email me and patches. Please also feel free to send me a message over Github or email at hubert.lepicki at gmail.com with questions, comments or criticism ;). Copyright (c) 2008 Hubert Lepicki, released under the MIT license