Skip to content
This repository has been archived by the owner on Aug 22, 2022. It is now read-only.

Commit

Permalink
refactor: avoid using arguments object
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Feb 26, 2020
1 parent ef7c96a commit 68c48f1
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions lib/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,21 @@ swig.setDefaults({
});

// Hack: Override for tag of Swig
swig.setTag('for', forTag.parse, function(compiler, args, content, parents, options, blockName) {
const compile = forTag.compile.apply(this, arguments).split('\n');
swig.setTag('for', forTag.parse, (...args) => {
const compile = forTag.compile(...args).split('\n');

compile.splice(3, 0, ' if (!Array.isArray(__l) && typeof __l.toArray === "function") { __l = __l.toArray(); }');

return compile.join('\n');
}, forTag.ends, true);

function swigRenderer(data, locals) {
return swig.render(data.text, {
locals: locals,
filename: data.path
function swigRenderer({ text, path }, locals) {
return swig.render(text, {
locals,
filename: path
});
}

swigRenderer.compile = function(data, locals) {
return swig.compile(data.text, {
filename: data.path
});
};
swigRenderer.compile = ({ text, path }) => swig.compile(text, { filename: path });

module.exports = swigRenderer;
module.exports = swigRenderer;

0 comments on commit 68c48f1

Please sign in to comment.