whacko icon indicating copy to clipboard operation
whacko copied to clipboard

Error: Encode is not a function

Open kheyse-autodesk opened this issue 8 years ago • 1 comments

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)

kheyse-autodesk avatar Apr 01 '16 14:04 kheyse-autodesk

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

kheyse-autodesk avatar Apr 01 '16 15:04 kheyse-autodesk