Class: Tilt::MarkabyTemplate

Inherits:
Template show all
Defined in:
lib/tilt/markaby.rb

Overview

Instance Attribute Summary

Attributes inherited from Template

#data, #file, #line, #options

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from Template

#basename, default_mime_type, default_mime_type=, #eval_file, #initialize, metadata, #metadata, #name, #render

Constructor Details

This class inherits a constructor from Tilt::Template

Class Method Details

+ (Object) builder_class



8
9
10
11
12
13
14
15
16
# File 'lib/tilt/markaby.rb', line 8

def self.builder_class
  @builder_class ||= Class.new(Markaby::Builder) do
    def __capture_markaby_tilt__(&block)
      __run_markaby_tilt__ do
        text capture(&block)
      end
    end
  end
end

Instance Method Details

- (Object) evaluate(scope, locals, &block)



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/tilt/markaby.rb', line 21

def evaluate(scope, locals, &block)
  builder = self.class.builder_class.new({}, scope)
  builder.locals = locals

  if data.kind_of? Proc
    (class << builder; self end).send(:define_method, :__run_markaby_tilt__, &data)
  else
    builder.instance_eval <<-CODE, __FILE__, __LINE__
      def __run_markaby_tilt__
        #{data}
      end
    CODE
  end

  if block
    builder.__capture_markaby_tilt__(&block)
  else
    builder.__run_markaby_tilt__
  end

  builder.to_s
end

- (Object) prepare



18
19
# File 'lib/tilt/markaby.rb', line 18

def prepare
end