Class: HamlCoffeeAssets::Tilt::TemplateHandler

Inherits:
Tilt::Template
  • Object
show all
Defined in:
lib/haml_coffee_assets/tilt/template_handler.rb

Overview

Haml Coffee template handler implementation for Tilt.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.engine_initialized?Boolean

Test if the compiler is initialized.

Returns:

  • (Boolean)

    the initialization status



18
19
20
# File 'lib/haml_coffee_assets/tilt/template_handler.rb', line 18

def self.engine_initialized?
  defined? HamlCoffeeAssets::Compiler
end

Instance Method Details

#evaluate(scope, locals = { }, &block) ⇒ Object

Compile the template.



35
36
37
38
39
40
41
# File 'lib/haml_coffee_assets/tilt/template_handler.rb', line 35

def evaluate(scope, locals = { }, &block)
  jst  = !!(scope.pathname.to_s =~ /\.jst\.hamlc(?:\.|$)/)
  name = scope.logical_path
  name = HamlCoffeeAssets.config.name_filter.call(name) if HamlCoffeeAssets.config.name_filter && !jst

  @output ||= HamlCoffeeAssets::Compiler.compile(name, data, !jst)
end

#initialize_engineObject

Initialize the template engine.



24
25
26
# File 'lib/haml_coffee_assets/tilt/template_handler.rb', line 24

def initialize_engine
  require_template_library 'haml_coffee_assets/compiler'
end

#prepareObject

Prepare the template



30
31
# File 'lib/haml_coffee_assets/tilt/template_handler.rb', line 30

def prepare
end