Class: MabTemplate
- Inherits:
-
Tilt::Template
- Object
- Tilt::Template
- MabTemplate
- Defined in:
- lib/mab/tilt.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.builder_class ⇒ Object
2 3 4 5 6 7 8 9 10 |
# File 'lib/mab/tilt.rb', line 2 def self.builder_class @builder_class ||= Class.new(Mab::Builder) do def __capture_mab_tilt__(&block) __run_mab_tilt__ do text capture(&block) end end end end |
Instance Method Details
#evaluate(scope, locals, &block) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/mab/tilt.rb', line 15 def evaluate(scope, locals, &block) builder = self.class.builder_class.new({}, scope) locals.each do |local, value| (class << builder; self end).send(:define_method, local, Proc.new { value }) end if data.kind_of? Proc (class << builder; self end).send(:define_method, :__run_mab_tilt__, &data) else builder.instance_eval " def __run_mab_tilt__\n capture(&Proc.new {\#{data}})\n end\n CODE\n end\n\n if block\n builder.__capture_mab_tilt__(&block)\n else\n builder.__run_mab_tilt__\n end\n\n builder\nend\n", __FILE__, __LINE__ |
#prepare ⇒ Object
12 13 |
# File 'lib/mab/tilt.rb', line 12 def prepare end |