Pass baseurl to templates

parent 73db70c7
/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){
......
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