Class: Malt::Engine::String

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

Overview

Ruby strings as template engine.

Instance Attribute Summary

Attributes inherited from Abstract

#settings

Instance Method Summary collapse

Methods inherited from Abstract

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

Constructor Details

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

Instance Method Details

#compile(params) ⇒ Object

Ruby compiles to Ruby. How odd. ;)



22
23
24
25
# File 'lib/malt/engines/string.rb', line 22

def compile(params)
  text = parameters(params, :text)
  "%{#{text}}"
end

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



14
15
16
17
18
19
# File 'lib/malt/engines/string.rb', line 14

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

  bind = make_binding(scope, locals, &content)
  eval("%{#{text}}", bind, file || '(eval)')
end