Class: HamlCoffeeAssets::HamlCoffeeTemplate

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

Overview

Haml CoffeeScript template implementation for Tilt.

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.name_filterObject

A proc that is called to modify the template name used as the JST key. The proc is passed the name as an argument and should return the modified name (or unmodified) name.



15
16
17
# File 'lib/haml_coffee_assets/haml_coffee_template.rb', line 15

def name_filter
  @name_filter
end

Class Method Details

.engine_initialized?Boolean

Test if the compiler is initialized.

Returns:

  • (Boolean)

    the initialization status



26
27
28
# File 'lib/haml_coffee_assets/haml_coffee_template.rb', line 26

def self.engine_initialized?
  defined? HamlCoffee
end

Instance Method Details

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

Compile the template.



43
44
45
46
47
48
# File 'lib/haml_coffee_assets/haml_coffee_template.rb', line 43

def evaluate(scope, locals = { }, &block)
  jst = scope.pathname.to_s =~ /\.jst\.hamlc(?:\.|$)/ ? false : true
  name = scope.logical_path
  name = self.class.name_filter.call(name) if self.class.name_filter && jst
  @output ||= HamlCoffee.compile(name, data, jst)
end

#initialize_engineObject

Initialize the template engine.



32
33
34
# File 'lib/haml_coffee_assets/haml_coffee_template.rb', line 32

def initialize_engine
  require_template_library 'haml_coffee'
end

#prepareObject

Prepare the template



38
39
# File 'lib/haml_coffee_assets/haml_coffee_template.rb', line 38

def prepare
end