Class: Usmu::Template::Helpers

Inherits:
Object
  • Object
show all
Defined in:
lib/usmu/template/helpers.rb

Overview

Helper functions that get imported into the local scope of templates

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ Helpers

Create a new Helpers instance. These are created on demand as needed by templates, there is not a singleton instance.



10
11
12
# File 'lib/usmu/template/helpers.rb', line 10

def initialize(configuration)
  @configuration = configuration
end

Instance Method Details

#include(name, args = {}) ⇒ String

Finds and renders a named include.

Parameters:

  • name (String)

    The name of the include file. Should not include file extension.

  • args (Hash) (defaults to: {})

    The named arguments to provide to the include file. These are incorporated as additional metadata available to the include file.

Returns:

  • (String)

    The rendered file.



24
25
26
27
28
# File 'lib/usmu/template/helpers.rb', line 24

def include(name, args = {})
  inc = Usmu::Template::Include.find_include(@configuration, name)
  inc.arguments = args
  inc.render
end