Class: Malt::Engine::RagTag

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

Overview

RagTag XML/HTML templates.

Instance Attribute Summary

Attributes inherited from Abstract

#settings

Instance Method Summary collapse

Methods inherited from Abstract

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

Constructor Details

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

Instance Method Details

#create_engine(params = {}) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/malt/engines/ragtag.rb', line 39

def create_engine(params={})
  text = parameters(params, :text)

  cached(text) do
    ::RagTag.new(text)
  end
end

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



30
31
32
33
34
35
36
# File 'lib/malt/engines/ragtag.rb', line 30

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

  binding = make_binding(scope, locals, &content)

  create_engine(params).compile(binding)
end

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



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

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

  case into
  when :html
    prepare_engine(params,&content).to_html
  when :xhtml
    prepare_engine(params,&content).to_xhtml
  when :xml
    prepare_engine(params,&content).to_xml
  else
    super(params, &content)
  end
end