Class: Hamlbars::Template

Inherits:
Tilt::Template
  • Object
show all
Includes:
Ext::RailsHelper
Defined in:
lib/hamlbars/template.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Ext::RailsHelper

included

Class Method Details

.engine_initialized?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/hamlbars/template.rb', line 11

def self.engine_initialized?
  defined? ::Haml::Engine
end

Instance Method Details

#evaluate(scope, locals, &block) ⇒ Object

Uses Haml to render the template into an HTML string, then wraps it in the neccessary JavaScript to serve to the client.



26
27
28
29
30
31
32
# File 'lib/hamlbars/template.rb', line 26

def evaluate(scope, locals, &block)
  if @engine.respond_to?(:precompiled_method_return_value, true)
    super(scope, locals, &block)
  else
    @engine.render(scope, locals, &block)
  end
end

#initialize_engineObject



15
16
17
# File 'lib/hamlbars/template.rb', line 15

def initialize_engine
  require_template_library 'haml'
end

#prepareObject



19
20
21
22
# File 'lib/hamlbars/template.rb', line 19

def prepare
  options = @options.merge(:filename => eval_file, :line => line)
  @engine = ::Haml::Engine.new(data, options)
end