Skip to content
Snippets Groups Projects
Verified Commit 87d8dea5 authored by Isabella Skořepová's avatar Isabella Skořepová
Browse files

Pass baseurl to templates

parent 73db70c7
No related branches found
No related tags found
No related merge requests found
/node_modules
*.log
/coverage
/build
/build-debug
......
......@@ -52,7 +52,7 @@ env.addFilter('relURL', function(filename, dir){
var formats = {};
module.exports = function(data, type) {
module.exports = function(data, type, config) {
return new Promise(function(resolve, reject) {
if(formats[type]) resolve(formats[type]);
else {
......@@ -99,7 +99,12 @@ module.exports = function(data, type) {
var promises = [];
tmpls.forEach(function(o) {
promises.push(new Promise(function(resolve, reject){
o.tmpl.render(data, function(err, val) {
var param = Object.assign({}, data, {
config: Object.assign({}, data.config, {
baseurl: config ? config.options.baseurl : ''
})
})
o.tmpl.render(param, function(err, val) {
if(err) {
//reject(new Error('Error rendering template '+o.file));
reject(err);
......
var jobs = require('./jobs');
module.exports = function(obj) {
module.exports = function(_obj) {
var obj = _obj;
console.log('Build step: Theme');
return new Promise(function(resolve,reject){
var todo = 0;
......@@ -10,7 +11,7 @@ module.exports = function(obj) {
var runJob = function(obj, type) {
todo++;
jobs.run('nunjucks', obj, type)
jobs.run('nunjucks', obj, type, _obj.config)
.then(function(data) {
if(!obj.rendered) obj.rendered = [];
data.forEach(function(o){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment