Class: CoffeeTemplate
- Inherits:
-
Tilt::Template
- Object
- Tilt::Template
- CoffeeTemplate
- Defined in:
- lib/sinatra/coffee.rb
Class Attribute Summary collapse
-
.coffee_path ⇒ Object
Returns the value of attribute coffee_path.
Instance Method Summary collapse
Class Attribute Details
.coffee_path ⇒ Object
Returns the value of attribute coffee_path.
14 15 16 |
# File 'lib/sinatra/coffee.rb', line 14 def coffee_path @coffee_path end |
Instance Method Details
#evaluate(scope, locals, &block) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/sinatra/coffee.rb', line 34 def evaluate(scope, locals, &block) compiled = nil = nil Open3.popen3(self.class.coffee_path, '-s', '-p', '--no-wrap') do |stdin, stdout, stderr, waitth| stdin.write(data) stdin.close_write compiled = stdout.read = stderr.read raise "CoffeeScript compile failed. #{}" unless waitth.value == 0 end compiled end |
#initialize_engine ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/sinatra/coffee.rb', line 17 def initialize_engine unless self.class.coffee_path ENV['PATH'].split(':').each do |p| coffee_path = File.join(p, 'coffee') if File.executable?(coffee_path) self.class.coffee_path = coffee_path break end end end raise StandardError, 'Unable to find "coffee" executable in your PATH' unless File.executable?(self.class.coffee_path) end |
#prepare ⇒ Object
31 32 |
# File 'lib/sinatra/coffee.rb', line 31 def prepare end |