Class: Guard::Templates::Jshaml::Compiler

Inherits:
Object
  • Object
show all
Defined in:
lib/guard/templates/jshaml/compiler.rb

Class Method Summary collapse

Class Method Details

.compile(str, target) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/guard/templates/jshaml/compiler.rb', line 7

def self.compile(str, target)
  engine  = ::Compiler.new
  code = engine.convert_from_string(str)

  return <<eos
function(locals) {
  with(locals || {}) {
    try {
      #{code};
      return _$output;
    } catch(e) {
      console.error(\"Error on file: #{target[:name]} around line \"+_$line+\"\\n Stack: \" + e.stack);
    }
  }
}
eos
end