Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
Revert change to wait for a more proper fix
Browse files Browse the repository at this point in the history
  • Loading branch information
claviska committed May 1, 2017
1 parent 80690f1 commit 4ad6ed2
Showing 1 changed file with 7 additions and 27 deletions.
34 changes: 7 additions & 27 deletions source/modules/helpers/theme_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';

Expand All @@ -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();
});
};

Expand Down

0 comments on commit 4ad6ed2

Please # to comment.