1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-07-05 09:30:04 +01:00

Merge pull request #95 from aruberto/partials-fix

load theme partials for non html and doc
This commit is contained in:
hacksalot 2016-01-07 18:30:54 -05:00
commit 9f22e94cf7

View File

@ -61,30 +61,31 @@ Definition of the HandlebarsGenerator class.
function registerPartials(format, theme) { function registerPartials(format, theme) {
if( format !== 'html' && format != 'doc' ) if( format === 'html' || format === 'doc' ) {
return;
// Locate the global partials folder // Locate the global partials folder
var partialsFolder = PATH.join( var partialsFolder = PATH.join(
parsePath( require.resolve('fresh-themes') ).dirname, parsePath( require.resolve('fresh-themes') ).dirname,
'/partials/', '/partials/',
format format
); );
// Register global partials in the /partials folder // Register global partials in the /partials folder
// TODO: Only do this once per HMR invocation. // TODO: Only do this once per HMR invocation.
_.each( READFILES( partialsFolder, function(error){ }), function( el ) { _.each( READFILES( partialsFolder, function(error){ }), function( el ) {
var pathInfo = parsePath( el ); var pathInfo = parsePath( el );
var name = SLASH( PATH.relative( partialsFolder, el ) var name = SLASH( PATH.relative( partialsFolder, el )
.replace(/\.html$|\.xml$/, '') ); .replace(/\.html$|\.xml$/, '') );
if( pathInfo.dirname.endsWith('section') ) { if( pathInfo.dirname.endsWith('section') ) {
name = SLASH(name.replace(/\.html$|\.xml$/, '')); name = SLASH(name.replace(/\.html$|\.xml$/, ''));
} }
var tplData = FS.readFileSync( el, 'utf8' ); var tplData = FS.readFileSync( el, 'utf8' );
var compiledTemplate = HANDLEBARS.compile( tplData ); var compiledTemplate = HANDLEBARS.compile( tplData );
HANDLEBARS.registerPartial( name, compiledTemplate ); HANDLEBARS.registerPartial( name, compiledTemplate );
theme.partialsInitialized = true; theme.partialsInitialized = true;
}); });
}
// Register theme-specific partials // Register theme-specific partials
_.each( theme.partials, function( el ) { _.each( theme.partials, function( el ) {