Class: MetaERB::MetaTemplate
- Inherits:
-
Object
- Object
- MetaERB::MetaTemplate
- Defined in:
- lib/meta_erb/meta_template.rb
Instance Method Summary collapse
-
#evaluate ⇒ String
Evaluates the DSL in @content and renders an ERB template.
-
#initialize(content, *args) ⇒ MetaTemplate
constructor
A new instance of MetaTemplate.
- #yield_proc(proc = nil, &block) ⇒ Object
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
#evaluate ⇒ String
Evaluates the DSL in @content and renders an ERB template.
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 |