Class: Tokamak::Hook::Tilt::TokamakTemplate

Inherits:
Tilt::Template
  • Object
show all
Defined in:
lib/tokamak/hook/tilt.rb

Instance Method Summary collapse

Instance Method Details

#initialize_engineObject



8
9
10
11
# File 'lib/tokamak/hook/tilt.rb', line 8

def initialize_engine
  return if defined?(::Tokamak)
  require_template_library 'tokamak'
end

#precompiled_postamble(locals) ⇒ Object



27
28
29
30
31
# File 'lib/tokamak/hook/tilt.rb', line 27

def precompiled_postamble(locals)
  <<-RUBY
    end
  RUBY
end

#precompiled_preamble(locals) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/tokamak/hook/tilt.rb', line 18

def precompiled_preamble(locals)
  local_assigns = super
  <<-RUBY
    begin
      extend ::Tokamak.builder_lookup(#{@media_type.inspect}).helper
      #{local_assigns}
  RUBY
end

#precompiled_template(locals) ⇒ Object



33
34
35
# File 'lib/tokamak/hook/tilt.rb', line 33

def precompiled_template(locals)
  data.to_str
end

#prepareObject



13
14
15
16
# File 'lib/tokamak/hook/tilt.rb', line 13

def prepare
  @media_type = options[:media_type]
  raise Tokamak::BuilderError.new("Content type required to build representation.") unless @media_type
end