whacko
whacko copied to clipboard
Error: Encode is not a function
When running
var whacko = require('whacko');
var a = whacko.load('<line x1="15" y1="-15" x2="15" y2="-40"/>', {
xmlMode: true
});
a.xml();
I get the error
whacko/lib/render.js:34
output += key + '="' + encode(value) + '"';
^
TypeError: encode is not a function
at formatAttrs (whacko/lib/render.js:34:36)
at renderTag (whacko/lib/render.js:132:19)
at whacko/lib/render.js:100:23
at arrayEach (whacko/node_modules/lodash/index.js:1289:13)
at Function.<anonymous> (whacko/node_modules/lodash/index.js:3345:13)
at module.exports (whacko/lib/render.js:95:7)
at whacko/lib/render.js:111:24
at arrayEach (whacko/node_modules/lodash/index.js:1289:13)
at Function.<anonymous> (whacko/node_modules/lodash/index.js:3345:13)
at module.exports (whacko/lib/render.js:95:7)
The hacky solution that got my code back running was to define encode as
encode = function(a){return a;};
A better solution may be to use https://www.npmjs.com/package/htmlencode or https://www.npmjs.com/package/node-html-encoder