Class: Tilt::CoffeeScriptTemplate

Inherits:
Template show all
Defined in:
lib/vendor/tilt-1.4.1/lib/tilt/coffee.rb

Overview

CoffeeScript template implementation. See: coffeescript.org/

CoffeeScript templates do not support object scopes, locals, or yield.

Constant Summary collapse

@@default_bare =
false

Instance Attribute Summary

Attributes inherited from Template

#data, #file, #line, #options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Template

#basename, #default_encoding, #eval_file, #initialize, #name, #read_template_file, #render

Constructor Details

This class inherits a constructor from Tilt::Template

Class Method Details

.default_bareObject



13
14
15
# File 'lib/vendor/tilt-1.4.1/lib/tilt/coffee.rb', line 13

def self.default_bare
  @@default_bare
end

.default_bare=(value) ⇒ Object



17
18
19
# File 'lib/vendor/tilt-1.4.1/lib/tilt/coffee.rb', line 17

def self.default_bare=(value)
  @@default_bare = value
end

.default_no_wrapObject

DEPRECATED



22
23
24
# File 'lib/vendor/tilt-1.4.1/lib/tilt/coffee.rb', line 22

def self.default_no_wrap
  @@default_bare
end

.default_no_wrap=(value) ⇒ Object

DEPRECATED



27
28
29
# File 'lib/vendor/tilt-1.4.1/lib/tilt/coffee.rb', line 27

def self.default_no_wrap=(value)
  @@default_bare = value
end

.engine_initialized?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/vendor/tilt-1.4.1/lib/tilt/coffee.rb', line 31

def self.engine_initialized?
  defined? ::CoffeeScript
end

Instance Method Details

#allows_script?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/vendor/tilt-1.4.1/lib/tilt/coffee.rb', line 49

def allows_script?
  false
end

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



45
46
47
# File 'lib/vendor/tilt-1.4.1/lib/tilt/coffee.rb', line 45

def evaluate(scope, locals, &block)
  @output ||= CoffeeScript.compile(data, options)
end

#initialize_engineObject



35
36
37
# File 'lib/vendor/tilt-1.4.1/lib/tilt/coffee.rb', line 35

def initialize_engine
  require_template_library 'coffee_script'
end

#prepareObject



39
40
41
42
43
# File 'lib/vendor/tilt-1.4.1/lib/tilt/coffee.rb', line 39

def prepare
  if !options.key?(:bare) and !options.key?(:no_wrap)
    options[:bare] = self.class.default_bare
  end
end