I'm trying to find a way to compile jade without having node install by using the ruby racer. I have this file:
https://github.com/visionmedia/jade/blob/master/jade.js which when loaded in a single html like this:
<html>
<head>
<script src='jade.js'></script>
</head>
<body>
jade is loaded.
</body>
</html>
Would let me do something like jade.compile('h1') This works perfectly in the browser (Chrome) and with ExecJS using node. But when I try this script:
#!/usr/bin/env ruby
puts "Compiling hellow world"
require 'rubygems'
require 'v8' #therubyracer
require 'execjs'
def jade_path
File.expand_path '../jade.js', __FILE__
end
def context
ExecJS.compile File.read(jade_path)
end
def hello
context.call "jade.compile('h1 Hola mundo')"
end
puts hello
All I get is 'V8::Error: jade is not defined'.
But I just don't understand why it doesn't work in V8, if I remove the v8 require and it falls back to node, then this ruby code works. So I don't know how to interact with this kind of files or what I'm missing from the docs. The Ruby Racer is the right way to go, because what I'm trying to solve is ruby developers avoiding jade because of the node dependency, but Jade is simply awesome and should be more widely used, even in Ruby.
Any help to understand how to use this kind of 'browserified' source files is appreciated. Thanks beforehand.