Class: Hypertemplate::Hook::Tilt::HypertemplateTemplate

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

Instance Method Summary collapse

Constructor Details

#initialize(registry, view = nil, line = 1, options = {}, &block) ⇒ HypertemplateTemplate

Returns a new instance of HypertemplateTemplate.



22
23
24
25
# File 'lib/hypertemplate/hook/tilt.rb', line 22

def initialize(registry, view = nil, line = 1,options = {}, &block)
  super(view, line, options, &block)
  @registry = registry
end

Instance Method Details

#initialize_engineObject



27
28
29
# File 'lib/hypertemplate/hook/tilt.rb', line 27

def initialize_engine
  require_template_library 'hypertemplate'
end

#precompiled_postamble(locals) ⇒ Object



50
51
52
53
54
# File 'lib/hypertemplate/hook/tilt.rb', line 50

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

#precompiled_preamble(locals) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/hypertemplate/hook/tilt.rb', line 36

def precompiled_preamble(locals)
  local_assigns = super
  <<-RUBY
    begin
      unless self.class.method_defined?(:hypertemplate_registry)
        def hypertemplate_registry
          env['hypertemplate']
        end
      end
      extend hypertemplate_registry[#{@media_type.inspect}].helper
      #{local_assigns}
  RUBY
end

#precompiled_template(locals) ⇒ Object



56
57
58
# File 'lib/hypertemplate/hook/tilt.rb', line 56

def precompiled_template(locals)
  data.to_str
end

#prepareObject



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

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