From 19a49c2778773ad5cba56ab4b151db3138945ab5 Mon Sep 17 00:00:00 2001 From: Benjamin Coe Date: Wed, 20 Apr 2016 23:22:48 -0700 Subject: [PATCH] fix: switch to precompiled template --- annotation.js | 68 +++++++++++++++++++++++++++++++++++++++++++++ annotation.mustache | 24 ++++++++++++++++ index.js | 30 +++----------------- package.json | 8 ++++-- 4 files changed, 102 insertions(+), 28 deletions(-) create mode 100644 annotation.js create mode 100644 annotation.mustache diff --git a/annotation.js b/annotation.js new file mode 100644 index 0000000..1c5185c --- /dev/null +++ b/annotation.js @@ -0,0 +1,68 @@ +(function() { + var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; +templates['annotation.mustache'] = template({"1":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing; + + return "
  • \n" + + ((stack1 = (helpers.hasKey || (depth0 && depth0.hasKey) || alias2).call(alias1,depth0,"image",{"name":"hasKey","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = (helpers.hasKey || (depth0 && depth0.hasKey) || alias2).call(alias1,depth0,"link",{"name":"hasKey","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = (helpers.hasKey || (depth0 && depth0.hasKey) || alias2).call(alias1,depth0,"text",{"name":"hasKey","hash":{},"fn":container.program(11, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "
  • \n"; +},"2":function(container,depth0,helpers,partials,data) { + var stack1, alias1=container.lambda; + + return " \""\n"; +},"4":function(container,depth0,helpers,partials,data) { + var stack1; + + return ((stack1 = (helpers.isArray || (depth0 && depth0.isArray) || helpers.helperMissing).call(depth0 != null ? depth0 : {},depth0,"link",{"name":"isArray","hash":{},"fn":container.program(5, data, 0),"inverse":container.program(9, data, 0),"data":data})) != null ? stack1 : ""); +},"5":function(container,depth0,helpers,partials,data) { + var stack1; + + return ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.link : depth0),{"name":"each","hash":{},"fn":container.program(6, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : ""); +},"6":function(container,depth0,helpers,partials,data) { + var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function"; + + return " " + + container.escapeExpression(((helper = (helper = helpers.text || (depth0 != null ? depth0.text : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"text","hash":{},"data":data}) : helper))) + + "" + + ((stack1 = helpers.unless.call(alias1,(data && data.last),{"name":"unless","hash":{},"fn":container.program(7, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "\n"; +},"7":function(container,depth0,helpers,partials,data) { + return ","; +},"9":function(container,depth0,helpers,partials,data) { + var stack1, alias1=container.lambda; + + return " " + + container.escapeExpression(alias1(((stack1 = (depth0 != null ? depth0.link : depth0)) != null ? stack1.text : stack1), depth0)) + + "\n"; +},"11":function(container,depth0,helpers,partials,data) { + var stack1, helper; + + return " " + + ((stack1 = ((helper = (helper = helpers.text || (depth0 != null ? depth0.text : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"text","hash":{},"data":data}) : helper))) != null ? stack1 : "") + + "\n"; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + return "
  • \n \n
  • \n"; +},"useData":true}); +})(); \ No newline at end of file diff --git a/annotation.mustache b/annotation.mustache new file mode 100644 index 0000000..a991bd1 --- /dev/null +++ b/annotation.mustache @@ -0,0 +1,24 @@ +
  • + +
  • diff --git a/index.js b/index.js index 122294e..48496d1 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,7 @@ var $ = require('jquery') -var Handlebars = require('handlebars') + +global.Handlebars = require('handlebars') +require('./annotation.js') function AnnotationPoller (opts) { this._installExtensions() @@ -8,31 +10,7 @@ function AnnotationPoller (opts) { this.pkg = opts.pkg // what package should we load annotations for? this.endpoint = '/api/v1/annotations/' + this.pkg this.annotations = {} - this.template = Handlebars.compile( - '
  • ' + - '' + - '
  • ') + this.template = Handlebars.templates['annotation.mustache'] this.addonSelector = '#npm-addon-box' } diff --git a/package.json b/package.json index 8ce5b3c..a384bfb 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "pretest": "standard", "test": "nyc mocha --timeout=10000 test.js", "coverage": "nyc report --reporter=text-lcov | coveralls", - "version": "standard-version" + "version": "standard-version", + "pretest": "handlebars annotation.mustache -f annotation.js" }, "repository": { "type": "git", @@ -39,5 +40,8 @@ "dependencies": { "handlebars": "^4.0.5", "jquery": "^2.2.2" + }, + "ignore": { + "ignore": ["annotation.js"] } -} \ No newline at end of file +}