Class: Malt::Engine::Mustache

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

Overview

Mustache 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

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

file, db, &content)


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

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

  locals = make_hash(scope, locals, &content)

  # convert symbol keys to strings w/o rewriting the hash
  symbol_keys = locals.keys.select{ |k| Symbol === k }
  symbol_keys.each do |k|
    locals[k.to_s] = locals[k]
    locals.delete(k)
  end

  #engine = intermediate(params)
  #engine.render(data)

  ::Mustache.render(text, locals)
end