From 4ad6ed2d41a186b1c15b5e3424018e6f91c687f4 Mon Sep 17 00:00:00 2001 From: Cory LaViska Date: Mon, 1 May 2017 15:57:06 -0400 Subject: [PATCH] Revert change to wait for a more proper fix --- source/modules/helpers/theme_helpers.js | 34 +++++-------------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/source/modules/helpers/theme_helpers.js b/source/modules/helpers/theme_helpers.js index 0cacc93..16c96b1 100644 --- a/source/modules/helpers/theme_helpers.js +++ b/source/modules/helpers/theme_helpers.js @@ -158,7 +158,9 @@ module.exports = (dust) => { return chunk.map((chunk) => { const locals = context.options.locals; const MakeUrl = require(Path.join(__basedir, 'source/modules/make_url.js'))(locals.Settings); + let isEditor = context.options.locals.isEditor; + let toolbar = Path.join(__basedir, 'source/views/partials/theme_toolbar.dust'); let script = MakeUrl.raw('assets/js/tinymce.bundle.js'); let html = ''; @@ -177,35 +179,13 @@ module.exports = (dust) => { html += '\n'; // Render the theme toolbar partial - // - // Note: for some reason, the method of rendering partials shown below causes a stack overflow - // when caching is enabled. This workaround compiles the theme toolbar on the fly, which is - // undesirable. However, it won't affect performance much since it only affects authenticated - // users. This is not a good way to render partials for all pages. - // - // Rendering partials from within helpers isn't covered by the docs so, for reference, the - // previous approach of rendering a partial looked like this: - // - // chunk.partial(templatePath, context).end(); - // if(locals.User) { - // Render the theme toolbar for authenticated users - let path = Path.join(__basedir, 'source/views/partials/theme_toolbar.dust'); - let src = Fs.readFileSync(path, 'utf8'); - let themeToolbar = dust.compile(src, 'theme_toolbar'); - - // Render the theme toolbar template in the current context - dust.loadSource(themeToolbar); - dust.render('theme_toolbar', context, (err, result) => { - html += result; - chunk = chunk.write(html); - return chunk.end(); - }); - } else { - // For unauthenticated users, dump what we have - chunk = chunk.write(html); - return chunk.end(); + chunk.partial(toolbar, context).end(); } + + chunk.write(html); + + return chunk.end(); }); };