From d76fadbd7d4f33b7fc208ce5242b37f0350ad493 Mon Sep 17 00:00:00 2001 From: Chris Kowalik Date: Sun, 20 Mar 2011 06:21:11 +0800 Subject: [PATCH] [action_view] docs for FileSystemResolver --- .../lib/action_view/template/resolver.rb | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/actionpack/lib/action_view/template/resolver.rb b/actionpack/lib/action_view/template/resolver.rb index 0966970a68..f9c52e3228 100644 --- a/actionpack/lib/action_view/template/resolver.rb +++ b/actionpack/lib/action_view/template/resolver.rb @@ -5,7 +5,7 @@ require "action_view/template" module ActionView # = Action View Resolver class Resolver - + # Keeps all information about view path and builds virtual path. class Path < String attr_reader :name, :prefix, :partial, :virtual alias_method :partial?, :partial @@ -180,7 +180,35 @@ module ActionView end end - # A resolver that loads files from the filesystem. + # A resolver that loads files from the filesystem. It allows to set your own + # resolving pattern. Such pattern can be a glob string supported by some variables. + # + # ==== Examples + # + # Default pattern, loads views the same way as previous versions of rails, eg. when you're + # looking for `users/new` it will produce query glob: `users/new{.{en},}{.{html,js},}{.{erb,haml,rjs},}` + # + # FileSystemResolver.new("/path/to/views", ":prefix/:action{.:locale,}{.:formats,}{.:handlers,}") + # + # This one allows you to keep files with different formats in seperated subdirectories, + # eg. `users/new.html` will be loaded from `users/html/new.erb` or `users/new.html.erb`, + # `users/new.js` from `users/js/new.erb` or `users/new.js.erb`, etc. + # + # FileSystemResolver.new("/path/to/views", ":prefix/{:formats/,}:action{.:locale,}{.:formats,}{.:handlers,}") + # + # If you don't specify pattern then the default will be used. + # + # ==== Pattern format and variables + # + # Pattern have to be a valid glob string, and it allows you to use the + # following variables: + # + # * :prefix - usualy the controller path + # * :action - name of the action + # * :locale - possible locale versions + # * :formats - possible file formats + # * :handlers - possible handlers + # class FileSystemResolver < PathResolver def initialize(path, pattern=nil) raise ArgumentError, "path already is a Resolver class" if path.is_a?(Resolver)