Phoenix.View.__using__
__using__
, go back to Phoenix.View module for more information.
When used, defines the current module as a main view module.
Options
:root
- the template root to find templates:path
- the optional path to search for templates within the:root
. Defaults to the underscored view module name. A blank string may be provided to use the:root
path directly as the template lookup path:namespace
- the namespace to consider when calculating view paths:pattern
- the wildcard pattern to apply to the root when finding templates. Default"*"
The :root
option is required while the :namespace
defaults to the
first nesting in the module name. For instance, both MyApp.UserView
and MyApp.Admin.UserView
have namespace MyApp
.
The :namespace
and :path
options are used to calculate template
lookup paths. For example, if you are in MyApp.UserView
and the
namespace is MyApp
, templates are expected at Path.join(root, "user")
.
On the other hand, if the view is MyApp.Admin.UserView
,
the path will be Path.join(root, "admin/user")
and so on. For
explicit root path locations, the :path
option can be provided instead.
The :root
and :path
are joined to form the final lookup path.
A blank string may be provided to use the :root
path directly as the
template lookup path.
Setting the namespace to MyApp.Admin
in the second example will force
the template to also be looked up at Path.join(root, "user")
.