From e1d399eec2aa50aa14f4aed0487eefc8ecbc967d Mon Sep 17 00:00:00 2001 From: Jerfferson Ferreira Date: Mon, 6 Mar 2017 08:57:18 -0300 Subject: [PATCH 1/2] Add locals object in pug render function --- lib/compilers/pug.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/compilers/pug.js b/lib/compilers/pug.js index 5740b0c..88b1aee 100644 --- a/lib/compilers/pug.js +++ b/lib/compilers/pug.js @@ -2,11 +2,16 @@ var ensureRequire = require('../ensure-require.js') module.exports = function (raw, cb, compiler) { ensureRequire('pug', 'pug') - var pug = require('pug') + var pug = require('pug'), + locals, + options = compiler.options.pug || {}; + + locals = options.data || {}; + try { - var html = pug.compile(raw, compiler.options.pug || {})() + var html = pug.compile(raw, options)(locals) } catch (err) { return cb(err) } cb(null, html) -} +} \ No newline at end of file From 8c1cbe91a89f1e3c640ae2477229cccd5c457792 Mon Sep 17 00:00:00 2001 From: Jerfferson Ferreira Date: Mon, 6 Mar 2017 10:06:54 -0300 Subject: [PATCH 2/2] Adjust to fit code style --- lib/compilers/pug.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/compilers/pug.js b/lib/compilers/pug.js index 88b1aee..9fddcb1 100644 --- a/lib/compilers/pug.js +++ b/lib/compilers/pug.js @@ -2,11 +2,11 @@ var ensureRequire = require('../ensure-require.js') module.exports = function (raw, cb, compiler) { ensureRequire('pug', 'pug') - var pug = require('pug'), - locals, - options = compiler.options.pug || {}; + var pug = require('pug') + var locals + var options = compiler.options.pug || {} - locals = options.data || {}; + locals = options.data || {} try { var html = pug.compile(raw, options)(locals) @@ -14,4 +14,4 @@ module.exports = function (raw, cb, compiler) { return cb(err) } cb(null, html) -} \ No newline at end of file +}