Class: Tilt::CoffeeScriptTemplate

Inherits:
Template
  • Object
show all
Defined in:
lib/tilt/coffee.rb

Overview

CoffeeScript template implementation. See: coffeescript.org/

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

Direct Known Subclasses

CoffeeScriptLiterateTemplate

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_mime_type, default_mime_type=, #eval_file, #initialize, metadata, #metadata, #name, #render

Constructor Details

This class inherits a constructor from Tilt::Template

Class Method Details

.default_bareObject



14
15
16
# File 'lib/tilt/coffee.rb', line 14

def self.default_bare
  @@default_bare
end

.default_bare=(value) ⇒ Object



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

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

.default_no_wrapObject

DEPRECATED



23
24
25
# File 'lib/tilt/coffee.rb', line 23

def self.default_no_wrap
  @@default_bare
end

.default_no_wrap=(value) ⇒ Object

DEPRECATED



28
29
30
# File 'lib/tilt/coffee.rb', line 28

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

.literate?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/tilt/coffee.rb', line 32

def self.literate?
  false
end

Instance Method Details

#allows_script?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/tilt/coffee.rb', line 47

def allows_script?
  false
end

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



43
44
45
# File 'lib/tilt/coffee.rb', line 43

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

#prepareObject



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

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