Class: MetaERB::MetaTemplate

Inherits:
Object
  • Object
show all
Defined in:
lib/meta_erb/meta_template.rb

Instance Method Summary collapse

Constructor Details

#initialize(content, *args) ⇒ MetaTemplate

Returns a new instance of MetaTemplate.



4
5
6
7
8
# File 'lib/meta_erb/meta_template.rb', line 4

def initialize(content, *args)
  @content    = content
  @proc_store = {}
  @args       = args
end

Instance Method Details

#evaluateString

Evaluates the DSL in @content and renders an ERB template.

Returns:

  • (String)

    The ERB template source.



13
14
15
# File 'lib/meta_erb/meta_template.rb', line 13

def evaluate
  MetaERB::ScopeEvaluator.new(self, ::GlobalScope, ::TopScope).evaluate(@content, *@args)
end

#yield_proc(proc = nil, &block) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/meta_erb/meta_template.rb', line 17

def yield_proc(proc=nil, &block)
  proc ||= block
  if Numeric === proc
    @proc_store[proc]
  else
    @proc_store[proc.object_id] = proc
  end
end