Class: Stitch::CoffeeScriptTemplate
- Inherits:
-
Tilt::Template
- Object
- Tilt::Template
- Stitch::CoffeeScriptTemplate
- Defined in:
- lib/stitch/coffee_script_template.rb
Constant Summary collapse
- @@default_bare =
false
- @@excludes =
[]
Class Method Summary collapse
- .default_bare ⇒ Object
- .default_bare=(value) ⇒ Object
- .engine_initialized? ⇒ Boolean
- .excludes=(excludes) ⇒ Object
- .javascripts_path ⇒ Object
Instance Method Summary collapse
Class Method Details
.default_bare ⇒ Object
9 10 11 |
# File 'lib/stitch/coffee_script_template.rb', line 9 def self. @@default_bare end |
.default_bare=(value) ⇒ Object
13 14 15 |
# File 'lib/stitch/coffee_script_template.rb', line 13 def self.(value) @@default_bare = value end |
.engine_initialized? ⇒ Boolean
19 20 21 |
# File 'lib/stitch/coffee_script_template.rb', line 19 def self.engine_initialized? defined? ::CoffeeScript end |
.excludes=(excludes) ⇒ Object
23 24 25 |
# File 'lib/stitch/coffee_script_template.rb', line 23 def self.excludes=(excludes) @@excludes = excludes end |
.javascripts_path ⇒ Object
27 28 29 |
# File 'lib/stitch/coffee_script_template.rb', line 27 def self.javascripts_path File.('../../assets/javascripts', __FILE__) end |
Instance Method Details
#evaluate(scope, locals, &block) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/stitch/coffee_script_template.rb', line 41 def evaluate(scope, locals, &block) name = module_name(scope) if (name == 'stitch_rails') || excluded?(name) @output ||= CoffeeScript.compile(data, ) else @output ||= <<JS require.define({ #{name.inspect}: function(exports, require, module) { #{indent_lines(CoffeeScript.compile(data, .merge(: => true)), 4)} } }); JS end end |
#initialize_engine ⇒ Object
31 32 33 |
# File 'lib/stitch/coffee_script_template.rb', line 31 def initialize_engine require_template_library 'coffee_script' end |
#prepare ⇒ Object
35 36 37 38 39 |
# File 'lib/stitch/coffee_script_template.rb', line 35 def prepare if !.key?(:bare) [:bare] = self.class. end end |