From fbfff2a4e4d9657f4b81f4e6aeae60e6d358b7bf Mon Sep 17 00:00:00 2001 From: Antonio Ruberto Date: Thu, 7 Jan 2016 16:39:46 -0500 Subject: [PATCH] load theme partials for non html and doc load global partials for html and doc only but load theme partials for all outputs --- src/renderers/handlebars-generator.js | 45 ++++++++++++++------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/renderers/handlebars-generator.js b/src/renderers/handlebars-generator.js index 4251e1a..7a96b5b 100644 --- a/src/renderers/handlebars-generator.js +++ b/src/renderers/handlebars-generator.js @@ -61,30 +61,31 @@ Definition of the HandlebarsGenerator class. function registerPartials(format, theme) { - if( format !== 'html' && format != 'doc' ) - return; + if( format === 'html' || format === 'doc' ) { - // Locate the global partials folder - var partialsFolder = PATH.join( - parsePath( require.resolve('fresh-themes') ).dirname, - '/partials/', - format - ); + // Locate the global partials folder + var partialsFolder = PATH.join( + parsePath( require.resolve('fresh-themes') ).dirname, + '/partials/', + format + ); - // Register global partials in the /partials folder - // TODO: Only do this once per HMR invocation. - _.each( READFILES( partialsFolder, function(error){ }), function( el ) { - var pathInfo = parsePath( el ); - var name = SLASH( PATH.relative( partialsFolder, el ) - .replace(/\.html$|\.xml$/, '') ); - if( pathInfo.dirname.endsWith('section') ) { - name = SLASH(name.replace(/\.html$|\.xml$/, '')); - } - var tplData = FS.readFileSync( el, 'utf8' ); - var compiledTemplate = HANDLEBARS.compile( tplData ); - HANDLEBARS.registerPartial( name, compiledTemplate ); - theme.partialsInitialized = true; - }); + // Register global partials in the /partials folder + // TODO: Only do this once per HMR invocation. + _.each( READFILES( partialsFolder, function(error){ }), function( el ) { + var pathInfo = parsePath( el ); + var name = SLASH( PATH.relative( partialsFolder, el ) + .replace(/\.html$|\.xml$/, '') ); + if( pathInfo.dirname.endsWith('section') ) { + name = SLASH(name.replace(/\.html$|\.xml$/, '')); + } + var tplData = FS.readFileSync( el, 'utf8' ); + var compiledTemplate = HANDLEBARS.compile( tplData ); + HANDLEBARS.registerPartial( name, compiledTemplate ); + theme.partialsInitialized = true; + }); + + } // Register theme-specific partials _.each( theme.partials, function( el ) {