1

I want to set a JSON object in client side javascript using swig. I tried with json filter of swig but it just print JSON object not assign. <script type="text/javascript"> var bootstrap = "{{locals.bootstrap | json}}"</script> as we know in Javascript this bootstrap variable is globally accessible in whole the application. but I am not able to set JSON object. I tried this var bootstrap = "{{locals.bootstrap}}" refer link . but its for just any property not for json object, its just set "[object,object]" in bootstrap not json object. I tried with json filter of swig refered link , but not get succeed.

Community
  • 1
  • 1
Bharat Bhushan
  • 2,077
  • 2
  • 21
  • 34

1 Answers1

1

Try

var bootstrap = "{{bootstrap | json | safe}}"

Subin Sebastian
  • 10,870
  • 3
  • 37
  • 42