Skip to content Skip to sidebar Skip to footer

Evaluate Custom Javascript Method (circularjson) With Jade

I want to parse an object into client-side javascript through Jade. Normally this would work: script var object = JSON.parse(#{JSON.stringify(object)}); but my object is circular

Solution 1:

It could be required and passed in the locals

response.render("index.jade", {CircularJSON : require('circular-json')});

Or it could be defined as a function in the scope of jade

- varCircularJSON = function(e,t){functionl(e,t,o){var u=[],...//whole function
script var player = CircularJSON.parse('!{CircularJSON.stringify(player)}');

Post a Comment for "Evaluate Custom Javascript Method (circularjson) With Jade"