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

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.engine_initialized?Boolean

Returns:

  • (Boolean)


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

def self.engine_initialized?
  defined? ::Tokamak
end

Instance Method Details

#initialize_engineObject



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

def initialize_engine
  require_template_library 'tokamak'
end

#precompiled_postamble(locals) ⇒ Object



30
31
32
33
34
# File 'lib/tokamak/hook/tilt.rb', line 30

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

#precompiled_preamble(locals) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/tokamak/hook/tilt.rb', line 21

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



36
37
38
# File 'lib/tokamak/hook/tilt.rb', line 36

def precompiled_template(locals)
  data.to_str
end

#prepareObject



16
17
18
19
# File 'lib/tokamak/hook/tilt.rb', line 16

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