Module: Zena::Use::ZafuEval::ViewMethods

Defined in:
lib/zena/use/zafu_eval.rb

Instance Method Summary collapse

Instance Method Details

#zafu_eval(node, code, opts) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/zena/use/zafu_eval.rb', line 5

def zafu_eval(node, code, opts)
  # Setup macro rendering context
  if opts[:template]
    master_template = secure(Node) { Node.find_by_zip(opts[:template]) }
  end
  path = opts[:zafu_url]
  parser = ::Zena::ZafuCompiler.new(code,
    :helper => self,
    :base_path        => path,
    :included_history => [path],
    :root             => path,
    :master_template  => master_template
  )
  
  # Setup starting context (note that a lot of the contextual information 
  # is lost: no up values).
  _node = node
  node_context = Zena::Use::NodeContext.new('_node', node.vclass)

  erb = parser.to_erb(
    :dev => false,
    :node => node_context,
    :master_template => master_template
  )
  # Geez if this works...
  ERB.new(erb).result(binding)
rescue => err
  err.message
end