Method: Lotus::View::Configuration#root

Defined in:
lib/lotus/view/configuration.rb

#root(value) ⇒ Object #rootPathname

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.

Examples:

Getting the value

require 'lotus/view'

Lotus::View.configuration.root # => #<Pathname:.>

Setting the value

require 'lotus/view'

Lotus::View.configure do
  root '/path/to/templates'
end

Lotus::View.configuration.root # => #<Pathname:/path/to/templates>

Overloads:

  • #root(value) ⇒ Object

    Sets the given value

    Parameters:

    • value (String, Pathname, #to_pathname)

      an object that can be coerced to Pathname

    Raises:

    • (Errno::ENOENT)

      if the given path doesn’t exist

  • #rootPathname

    Gets the value

    Returns:

    • (Pathname)

See Also:

Since:

  • 0.2.0



185
186
187
188
189
190
191
# File 'lib/lotus/view/configuration.rb', line 185

def root(value = nil)
  if value
    @root = Utils::Kernel.Pathname(value).realpath
  else
    @root
  end
end