From 32cdaf39bbcf445b718f7d2b6066ce336358dba7 Mon Sep 17 00:00:00 2001 From: Arun Date: Tue, 8 May 2018 10:49:56 +0530 Subject: [PATCH 1/2] move require path to function --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 20fe1c917d..efacb0fd04 100644 --- a/index.js +++ b/index.js @@ -4,7 +4,6 @@ const assert = require('./src/util/assert.js') const tokenizer = require('./src/tokenizer.js') const statFileAsync = require('./src/util/fs.js').statFileAsync const readFileAsync = require('./src/util/fs.js').readFileAsync -const path = require('path') const url = require('./src/util/url.js') const Render = require('./src/render.js') const lexical = require('./src/lexical.js') @@ -64,6 +63,7 @@ var _engine = { return this.tag.register(name, tag) }, lookup: function (filepath, root) { + const path = require('path') root = this.options.root.concat(root || []) root = _.uniq(root) var paths = root.map(root => path.resolve(root, filepath)) @@ -79,6 +79,7 @@ var _engine = { : this.getTemplateFromUrl(filepath, root) }, getTemplateFromFile: function (filepath, root) { + const path = require('path') if (!path.extname(filepath)) { filepath += this.options.extname } From 3e6c1cd582bb7a5439249d8fb081b19a20fd5a2d Mon Sep 17 00:00:00 2001 From: Arun Date: Tue, 8 May 2018 14:01:29 +0530 Subject: [PATCH 2/2] comment unsed breaking function --- index.js | 64 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/index.js b/index.js index efacb0fd04..0c8bd830f1 100644 --- a/index.js +++ b/index.js @@ -62,43 +62,43 @@ var _engine = { registerTag: function (name, tag) { return this.tag.register(name, tag) }, - lookup: function (filepath, root) { - const path = require('path') - root = this.options.root.concat(root || []) - root = _.uniq(root) - var paths = root.map(root => path.resolve(root, filepath)) - return anySeries(paths, path => statFileAsync(path).then(() => path)) - .catch((e) => { - e.message = `${e.code}: Failed to lookup ${filepath} in: ${root}` - throw e - }) - }, + // lookup: function (filepath, root) { + // const path = require('path') + // root = this.options.root.concat(root || []) + // root = _.uniq(root) + // var paths = root.map(root => path.resolve(root, filepath)) + // return anySeries(paths, path => statFileAsync(path).then(() => path)) + // .catch((e) => { + // e.message = `${e.code}: Failed to lookup ${filepath} in: ${root}` + // throw e + // }) + // }, getTemplate: function (filepath, root) { return typeof XMLHttpRequest === 'undefined' ? this.getTemplateFromFile(filepath, root) : this.getTemplateFromUrl(filepath, root) }, - getTemplateFromFile: function (filepath, root) { - const path = require('path') - if (!path.extname(filepath)) { - filepath += this.options.extname - } - return this - .lookup(filepath, root) - .then(filepath => { - if (this.options.cache) { - var tpl = this.cache[filepath] - if (tpl) { - return Promise.resolve(tpl) - } - return readFileAsync(filepath) - .then(str => this.parse(str)) - .then(tpl => (this.cache[filepath] = tpl)) - } else { - return readFileAsync(filepath).then(str => this.parse(str, filepath)) - } - }) - }, + // getTemplateFromFile: function (filepath, root) { + // const path = require('path') + // if (!path.extname(filepath)) { + // filepath += this.options.extname + // } + // return this + // .lookup(filepath, root) + // .then(filepath => { + // if (this.options.cache) { + // var tpl = this.cache[filepath] + // if (tpl) { + // return Promise.resolve(tpl) + // } + // return readFileAsync(filepath) + // .then(str => this.parse(str)) + // .then(tpl => (this.cache[filepath] = tpl)) + // } else { + // return readFileAsync(filepath).then(str => this.parse(str, filepath)) + // } + // }) + // }, getTemplateFromUrl: function (filepath, root) { var fullUrl if (url.valid(filepath)) {