Commit 87d8dea5 authored by Isabella Skořepová's avatar Isabella Skořepová

Pass baseurl to templates

parent 73db70c7
/node_modules /node_modules
*.log
/coverage /coverage
/build /build
/build-debug /build-debug
......
...@@ -52,7 +52,7 @@ env.addFilter('relURL', function(filename, dir){ ...@@ -52,7 +52,7 @@ env.addFilter('relURL', function(filename, dir){
var formats = {}; var formats = {};
module.exports = function(data, type) { module.exports = function(data, type, config) {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
if(formats[type]) resolve(formats[type]); if(formats[type]) resolve(formats[type]);
else { else {
...@@ -99,7 +99,12 @@ module.exports = function(data, type) { ...@@ -99,7 +99,12 @@ module.exports = function(data, type) {
var promises = []; var promises = [];
tmpls.forEach(function(o) { tmpls.forEach(function(o) {
promises.push(new Promise(function(resolve, reject){ 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) { if(err) {
//reject(new Error('Error rendering template '+o.file)); //reject(new Error('Error rendering template '+o.file));
reject(err); reject(err);
......
var jobs = require('./jobs'); var jobs = require('./jobs');
module.exports = function(obj) { module.exports = function(_obj) {
var obj = _obj;
console.log('Build step: Theme'); console.log('Build step: Theme');
return new Promise(function(resolve,reject){ return new Promise(function(resolve,reject){
var todo = 0; var todo = 0;
...@@ -10,7 +11,7 @@ module.exports = function(obj) { ...@@ -10,7 +11,7 @@ module.exports = function(obj) {
var runJob = function(obj, type) { var runJob = function(obj, type) {
todo++; todo++;
jobs.run('nunjucks', obj, type) jobs.run('nunjucks', obj, type, _obj.config)
.then(function(data) { .then(function(data) {
if(!obj.rendered) obj.rendered = []; if(!obj.rendered) obj.rendered = [];
data.forEach(function(o){ data.forEach(function(o){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment