lib/linner/wrapper.rb in linner-0.4.6 vs lib/linner/wrapper.rb in linner-0.5.0

- old
+ new

@@ -1,17 +1,32 @@ module Linner - class Wrapper - WRAPPER = - 'this.require.define({"%s":' + - 'function(exports, require, module){' + - '%s' + - ";}});\n" + module Wrapper + class Module + def self.wrap(name, content) + <<-WRAPPER +this.require.define({"#{name}":function(exports, require, module){#{content};}}); + WRAPPER + end - def self.wrap(name, content) - WRAPPER % [name, content] + def self.definition + File.read(File.join File.dirname(__FILE__), "../../vendor", "require_definition.js") + end end - def self.definition - File.read(File.join File.dirname(__FILE__), "../../vendor", "require_definition.js") + class Template + def self.wrap(name, content) + <<-WRAPPER +templates["#{name}"] = template(#{content}); + WRAPPER + end + + def self.definition(content) + <<-DEFINITION +(function() { + var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; + #{content} +})(); + DEFINITION + end end end end