From 6604ea4fdbb8e088b4a4f7f543f718ebe3214352 Mon Sep 17 00:00:00 2001 From: pk1a Date: Wed, 5 Mar 2014 17:55:42 +0100 Subject: [PATCH] fix: require rt only once in a compiled template Fixes #85 Closes #94 --- hsp/compiler/jsgenerator/index.js | 2 +- public/test/compiler/tests.js | 2 +- public/test/rt/cptbinding.spec.hsp | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hsp/compiler/jsgenerator/index.js b/hsp/compiler/jsgenerator/index.js index 2890e70..995083b 100644 --- a/hsp/compiler/jsgenerator/index.js +++ b/hsp/compiler/jsgenerator/index.js @@ -10,7 +10,7 @@ var HEADER_ARR = [ '// This file has been generated by the hashspace compiler ', '// Direct MODIFICATIONS WILL BE LOST when the file is recompiled! ', '// ################################################################ ', - '', 'var hsp=require("hsp/rt");', '']; + '']; var HEADER = module.exports.HEADER = HEADER_ARR.join('\r\n'); var HEADER_SZ = HEADER_ARR.length; diff --git a/public/test/compiler/tests.js b/public/test/compiler/tests.js index aab98e5..534809a 100644 --- a/public/test/compiler/tests.js +++ b/public/test/compiler/tests.js @@ -146,7 +146,7 @@ describe('Block Parser: ', function () { // assert.equal(r.code,s,"template generated code"); // strange issue with non visible characters assert.equal(ut.compareJSCode(r.code.replace(/\r/g, ""), s), "", "template generated code"); - var lm = [0, 7, 8, 9, 10, 10, 10, 15, 16, 17, 18, 19, 19, 19, 19, 24]; + var lm = [0, 5, 6, 7, 8, 8, 8, 13, 14, 15, 16, 17, 17, 17, 17, 22]; assert.equal(ut.jsonContains(r.lineMap, lm, "lineMap"), "", "line map comparison"); }); diff --git a/public/test/rt/cptbinding.spec.hsp b/public/test/rt/cptbinding.spec.hsp index caafd50..f356e54 100644 --- a/public/test/rt/cptbinding.spec.hsp +++ b/public/test/rt/cptbinding.spec.hsp @@ -1,4 +1,5 @@ var klass=require("hsp/klass"), + hsp=require("hsp/rt"), fireEvent=require("hsp/utils/eventgenerator").fireEvent, json=require("hsp/json");