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.

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

Instance Method Details

#allows_script?Boolean

Returns:

  • (Boolean)


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

def allows_script?
  false
end

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



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

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

#prepareObject



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

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