Module: Armadillo

Defined in:
lib/armadillo.rb

Defined Under Namespace

Classes: TemplateContext

Constant Summary collapse

VERSION =
"0.0.6"
DEFAULT_OPTIONS =
{
  :default_encoding => Encoding.default_external,
  :outvar => "@_output"
}

Class Method Summary collapse

Class Method Details

.render(template_path, locals = {}, options = {}) ⇒ String

Note:

options also accepts any options offered by the Erubis templating system.

Render the erb template.

Parameters:

  • template_path (String)
  • locals (Hash) (defaults to: {})
  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :scope (Object) — default: Object.new

    Any object you want to bound to the template scope.

  • :base_path (String, nil) — default: nil

    The path of the directory for which the templates are going to be searched on.

Returns:

  • (String)


144
145
146
147
148
# File 'lib/armadillo.rb', line 144

def self.render(template_path, locals = {}, options = {})
  scope = options.fetch(:scope) { Object.new }
  context = TemplateContext.new(scope, options)
  _render(template_path, locals, context, options)
end