Class: Theme::MabTemplate

Inherits:
Tilt::Template
  • Object
show all
Defined in:
lib/theme/mab.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.builder_classObject



9
10
11
12
13
14
15
16
17
# File 'lib/theme/mab.rb', line 9

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



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/theme/mab.rb', line 22

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 <<-CODE, __FILE__, __LINE__
      def __run_mab_tilt__
        capture(&Proc.new {#{data}})
      end
    CODE
  end

  if block
    builder.__capture_mab_tilt__(&block)
  else
    builder.__run_mab_tilt__
  end

  builder
end

#prepareObject



19
20
# File 'lib/theme/mab.rb', line 19

def prepare
end