Browse Source

Fix handlebars path issue on Windows OS.

pull/3/head
Roman Axelrod 3 years ago
parent
commit
840f73d739
  1. 11
      server.js

11
server.js

@ -77,7 +77,7 @@ app.get('/', async (req, res) => {
data.helpers = {
port,
include_partial: (filesPath) => path.join(modulesPath, filesPath),
include_partial: (filesPath) => handlebarLayoutsPath(modulesPath, filesPath),
baseView,
previewFrameUrl: `${previewFrameUrl}/${baseViewUrl}`,
}
@ -95,8 +95,8 @@ app.get('/view/:baseView', async (req, res) => {
const blockName = config.has('blockName') ? config.get('blockName') : developmentBlockName;
data.helpers = {
include_partial: (filesPath) => path.join(modulesPath, filesPath),
include_block_template: () => path.join(projectPath, 'src', `${blockName}.template`),
include_partial: (filesPath) => handlebarLayoutsPath(modulesPath, filesPath),
include_block_template: () => handlebarLayoutsPath(projectPath, 'src', `${blockName}.template`),
section_class: `${blockName}--${jsonFileName}`,
base_url: '/'
}
@ -396,3 +396,8 @@ function handleSyntaxErrors(err, req, res, next) {
next();
}
function handlebarLayoutsPath() {
return path.join(...arguments)
.replace(/\\/g, '/'); // Windows path issue. Fix all "\" for Handlebars.
}

Loading…
Cancel
Save