Skip to content

Commit

Permalink
feat: strf-7175 bump paper to 3.0.0-rc.19
Browse files Browse the repository at this point in the history
  • Loading branch information
bc-williamkwon committed Aug 2, 2019
1 parent cbbe808 commit eb5ef78
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 66 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"modules": true
},
"env": {
"es6": true,
"node": true
},
"globals": {
Expand Down
110 changes: 71 additions & 39 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"homepage": "https://github.com/bigcommerce/stencil-cli",
"dependencies": {
"@bigcommerce/stencil-paper": "^2.0.18",
"@bigcommerce/stencil-paper": "3.0.0-rc.19",
"@bigcommerce/stencil-styles": "1.1.0",
"accept-language-parser": "^1.0.2",
"archiver": "^0.14.4",
Expand Down
39 changes: 24 additions & 15 deletions server/plugins/renderer/renderer.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,24 +458,33 @@ internals.getHeaders = function (request, options, config) {
* @type {Object}
*/
internals.themeAssembler = {
getTemplates: (path, processor, callback) => {
TemplateAssembler.assemble(internals.getThemeTemplatesPath(), path, (err, templates) => {
if (templates[path]) {
// Check if the string includes frontmatter configuration and remove it
var match = templates[path].match(/---\r?\n[\S\s]*\r?\n---\r?\n([\S\s]*)$/);

if (_.isObject(match) && match[1]) {
templates[path] = match[1];
getTemplates: (path, processor) => {
return new Promise((resolve, reject) => {
TemplateAssembler.assemble(internals.getThemeTemplatesPath(), path, (err, templates) => {
if (err) {
return reject(err);
}
}
if (templates[path]) {
// Check if the string includes frontmatter configuration and remove it
const match = templates[path].match(/---\r?\n[\S\s]*\r?\n---\r?\n([\S\s]*)$/);

callback(null, processor(templates));
});
if (_.isObject(match) && match[1]) {
templates[path] = match[1];
}
}
return resolve(processor(templates));
});
})
},
getTranslations: (callback) => {
LangAssembler.assemble((err, translations) => {
callback(null, _.mapValues(translations, locales => JSON.parse(locales)));
});
getTranslations: () => {
return new Promise((resolve, reject) => {
LangAssembler.assemble((err, translations) => {
if (err) {
return reject(err);
}
return resolve(_.mapValues(translations, locales => JSON.parse(locales)));
});
})
},
};

Expand Down
17 changes: 6 additions & 11 deletions server/plugins/renderer/responses/pencil-response.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ const internals = {};

module.exports = function (data, assembler) {
this.respond = function (request, reply) {
var response,
output,
paper,
templatePath;

var paper = new Paper(data.context.settings, data.context.theme_settings, assembler);
const paper = new Paper(data.context.settings, data.context.theme_settings, assembler, "handlebars-v3");

// Set the environment to dev
data.context.in_development = true;
Expand All @@ -22,21 +17,21 @@ module.exports = function (data, assembler) {
paper.addDecorator(decorator);
})

templatePath = internals.getTemplatePath(request, data);
const templatePath = internals.getTemplatePath(request, data);

paper.loadTheme(templatePath, data.acceptLanguage, function () {
paper.loadTheme(templatePath, data.acceptLanguage).then(() => {
if (request.query.debug === 'context') {
return reply(data.context);
}

output = paper.renderTheme(templatePath, data);
response = reply(output);
const output = paper.renderTheme(templatePath, data);
const response = reply(output);
response.code(data.statusCode);

if (data.headers['set-cookie']) {
response.header('set-cookie', data.headers['set-cookie']);
}
});
}).catch(err => console.error(err.message.red));
};
};

Expand Down

0 comments on commit eb5ef78

Please sign in to comment.