Class: Jade::Compiler
- Inherits:
-
Object
- Object
- Jade::Compiler
- Defined in:
- lib/jade/compiler.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #compile(template) ⇒ Object
- #context ⇒ Object
-
#initialize(options = {}) ⇒ Compiler
constructor
A new instance of Compiler.
- #jade_version ⇒ Object
- #source ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Compiler
Returns a new instance of Compiler.
7 8 9 10 11 12 |
# File 'lib/jade/compiler.rb', line 7 def initialize(={}) @options = { :client => true, :compileDebug => false }.merge end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'lib/jade/compiler.rb', line 5 def @options end |
Instance Method Details
#compile(template) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/jade/compiler.rb', line 30 def compile(template) template = template.read if template.respond_to?(:read) template = context.eval("jade.precompile(#{template.to_json}, #{@options.to_json})") %{ function(locals){ #{template} } } end |
#context ⇒ Object
22 23 24 |
# File 'lib/jade/compiler.rb', line 22 def context @context ||= ExecJS.compile source end |
#jade_version ⇒ Object
26 27 28 |
# File 'lib/jade/compiler.rb', line 26 def jade_version context.eval("jade.version") end |