Skip to content
Browse files

[action_view] docs for FileSystemResolver

  • Loading branch information...
1 parent de1fe5e commit d76fadbd7d4f33b7fc208ce5242b37f0350ad493 @nu7hatch nu7hatch committed with josevalim Mar 20, 2011
Showing with 30 additions and 2 deletions.
  1. +30 −2 actionpack/lib/action_view/template/resolver.rb
View
32 actionpack/lib/action_view/template/resolver.rb
@@ -5,7 +5,7 @@
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 @@ def extract_handler_and_format(path, default_formats)
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:
+ #
+ # * <tt>:prefix</tt> - usualy the controller path
+ # * <tt>:action</tt> - name of the action
+ # * <tt>:locale</tt> - possible locale versions
+ # * <tt>:formats</tt> - possible file formats
+ # * <tt>:handlers</tt> - possible handlers
+ #
class FileSystemResolver < PathResolver
def initialize(path, pattern=nil)
raise ArgumentError, "path already is a Resolver class" if path.is_a?(Resolver)

0 comments on commit d76fadb

Please sign in to comment.
Something went wrong with that request. Please try again.