Class: Hanami::View::Configuration
- Inherits:
-
Object
- Object
- Hanami::View::Configuration
- Defined in:
- gems/gems/hanami-view-1.3.3/lib/hanami/view/configuration.rb
Overview
Configuration for the framework, controllers and actions.
Hanami::Controller has its own global configuration that can be manipulated via Hanami::View.configure
.
Every time that Hanami::View
and Hanami::Layout
are included, that global configuration is being copied to the recipient. The copy will inherit all the settings from the original, but all the subsequent changes aren’t reflected from the parent to the children, and viceversa.
This architecture allows to have a global configuration that capture the most common cases for an application, and let views and layouts layouts to specify exceptions.
Instance Attribute Summary collapse
-
#default_encoding(value = nil) ⇒ Object
readonly
Default encoding for templates.
-
#layout(value = nil) ⇒ Object
readonly
Set the global layout.
- #layouts ⇒ Object readonly
- #load_paths ⇒ Object readonly
- #modules ⇒ Object readonly
-
#namespace(value = nil) ⇒ Object
readonly
Set the Ruby namespace where to lookup for views.
- #partials ⇒ Object readonly
-
#root(value = nil) ⇒ Object
readonly
Set the root path where to search for templates.
- #views ⇒ Object readonly
Instance Method Summary collapse
-
#initialize ⇒ Hanami::View::Configuration
constructor
Initialize a configuration instance.
-
#prepare(&blk) ⇒ void
Prepare the views.
Constructor Details
#initialize ⇒ Hanami::View::Configuration
Initialize a configuration instance
Source: | on GitHub
def initialize @namespace = Object reset! end |
Instance Attribute Details
#default_encoding(value) ⇒ Object #default_encoding ⇒ Encoding
Default encoding for templates
This is part of a DSL, for this reason when this method is called with an argument, it will set the corresponding instance variable. When called without, it will return the already set value, or the default.
Source: | on GitHub
def default_encoding(value = nil) if value.nil? @default_encoding else @default_encoding = Encoding.find(value) end end |
#layout(value) ⇒ Object #layout ⇒ Class
Set the global layout
If not set, this value defaults to nil
, while at the rendering time it will use Hanami::View::Rendering::NullLayout
.
This is part of a DSL, for this reason when this method is called with an argument, it will set the corresponding instance variable. When called without, it will return the already set value, or the default.
#namespace(value) ⇒ Object #namespace ⇒ Class, ...
Set the Ruby namespace where to lookup for views.
When multiple instances of the framework are used, we want to make sure that if a MyApp
wants a Dashboard::Index
view, we are loading the right one.
If not set, this value defaults to Object
.
This is part of a DSL, for this reason when this method is called with an argument, it will set the corresponding instance variable. When called without, it will return the already set value, or the default.
Source: | on GitHub
def namespace(value = nil) if value @namespace = value else @namespace end end |
#root(value) ⇒ Object #root ⇒ Pathname
Set the root path where to search for templates
If not set, this value defaults to the current directory.
This is part of a DSL, for this reason when this method is called with an argument, it will set the corresponding instance variable. When called without, it will return the already set value, or the default.
Instance Method Details
#prepare(&blk) ⇒ void
This method returns an undefined value.
Prepare the views.
The given block will be yielded when Hanami::View
will be included by a view.
This method can be called multiple times.
Source: | on GitHub
def prepare(&blk) if block_given? @modules.push(blk) else raise ArgumentError.new('Please provide a block') end end |