Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: strf-7175 bump paper to 3.0.0-rc.19 #500

Merged
merged 1 commit into from
Aug 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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