-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathtilt_jade.rb
40 lines (32 loc) · 991 Bytes
/
tilt_jade.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# encoding: utf-8
require 'tilt'
require 'open3'
if defined? Serve
if !Serve::DynamicHandler.extensions.include?('jade')
App.alert('Jade Template engine is not loaded, restart Fire.app and watch this project first')
end
end
module Tilt
class JadeTemplate < Template
self.default_mime_type = "text/html"
def prepare
end
def evaluate(scope, locals, &block)
if File.exists?('c:/users/etblue/appdata/roaming/npm/node_modules/jade/bin/jade.js')
jade_cmd = 'node c:/users/etblue/appdata/roaming/npm/node_modules/jade/bin/jade.js --path . -O "{require: require}" -P '
else
jade_cmd = 'jade --path . -O "{require: require}" -P'
end
pwd = Dir.pwd
#Dir.chdir('views')
body = Open3.popen3(jade_cmd) do |stdin, stdout, stderr|
stdin.write data
stdin.close
stdout.read + stderr.read.gsub(/\n/, '<br>')
end
Dir.chdir(pwd)
body
end
end
register JadeTemplate, 'jade'
end