module Roda::RodaPlugins::ViewSubdirs
The view_subdirs plugin is designed for sites that have outgrown a flat view directory and use subdirectories for views. It allows you to set the view directory to use, and template names that do not contain a slash will automatically use that view subdirectory. Example:
plugin :render, :layout=>'./layout' plugin :view_subdirs route do |r| r.on "users" do set_view_subdir 'users' r.get :id do view 'profile' # uses ./views/users/profile.erb end r.get 'list' do view 'lists/users' # uses ./views/lists/users.erb end end end
This plugin should be loaded after the render plugin, since it works by overriding parts of the render plugin.
Note that when a view subdirectory is set, the layout will also be looked up in the subdirectory unless it contains a slash. So if you want to use a view subdirectory for templates but have a shared layout, you should make sure your layout contains a slash, similar to the example above.