From dcfc651d3dda86f68b83b6aa30aedcf061521d10 Mon Sep 17 00:00:00 2001 From: ernscht Date: Sat, 19 Mar 2016 23:32:25 +0100 Subject: [PATCH] move logAndRenderError to utils --- app/templates/app/core/utils.js | 11 ++++++++++- app/templates/app/helpers/component.js | 9 +-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/app/templates/app/core/utils.js b/app/templates/app/core/utils.js index b8ab3af67..592c3f6af 100644 --- a/app/templates/app/core/utils.js +++ b/app/templates/app/core/utils.js @@ -1,4 +1,5 @@ var fs = require('fs'); +var hbs = require('hbs'); function fileExistsSync(filename) { // Substitution for the deprecated fs.existsSync() method @see https://nodejs.org/api/fs.html#fs_fs_existssync_path @@ -11,6 +12,14 @@ function fileExistsSync(filename) { } } +function logAndRenderError(e) { + console.info(e.message); + return new hbs.handlebars.SafeString( + '

' + e.message + '

' + ); +} + module.exports = { - fileExistsSync: fileExistsSync + fileExistsSync: fileExistsSync, + logAndRenderError: logAndRenderError }; diff --git a/app/templates/app/helpers/component.js b/app/templates/app/helpers/component.js index a49ff9ca4..33e71dbe4 100644 --- a/app/templates/app/helpers/component.js +++ b/app/templates/app/helpers/component.js @@ -7,13 +7,6 @@ var utils = require('../core/utils'); module.exports = function () { - var logAndRenderError = function logAndRenderError(e) { - console.info(e.message); - return new hbs.handlebars.SafeString( - '

' + e.message + '

' - ); - }; - try { var context = arguments[arguments.length - 1]; var contextDataRoot = context.data && context.data.root ? context.data.root : {}; // default component data from controller & view @@ -98,6 +91,6 @@ module.exports = function () { throw new Error('Component `' + name + '` with template file `'+ templateFile + '.' + cfg.nitro.view_file_extension + '` not found in folder `' + folder + '`.'); } catch (e) { - return logAndRenderError(e); + return utils.logAndRenderError(e); } };