Class: Malt::Engine::Radius

Inherits:
Abstract show all
Defined in:
lib/malt/engines/radius.rb

Overview

Radius Template

http://github.com/jlong/radius/

Instance Attribute Summary

Attributes inherited from Abstract

#settings

Instance Method Summary collapse

Methods inherited from Abstract

#cache?, #create_engine, default, #initialize, register, type

Constructor Details

This class inherits a constructor from Malt::Engine::Abstract

Instance Method Details

#prepare_engine(params = {}, &content) ⇒ Object


30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/malt/engines/radius.rb', line 30

def prepare_engine(params={}, &content)
  scope, locals = parameters(params, :scope, :locals)

  locals ||= {}

  # convert string keys to symbols w/o rewriting the hash
  string_keys = locals.keys.select{ |k| String === k }
  string_keys.each do |k|
    locals[k.to_sym] = locals[k]
    locals.delete(k)
  end

  make_context(scope, locals, &content)
end

#render(params = {}, &content) ⇒ Object


14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/malt/engines/radius.rb', line 14

def render(params={}, &content)
  into, text = parameters(params, :to, :text)

  case into
  when :html, :xml, nil
    context = prepare_engine(params, &content)
    options = engine_options(params)

    parser = ::Radius::Parser.new(context, options)
    parser.parse(text)
  else
    super(params, &content)
  end
end