Considering the following context:
{
dogs: [ {name: "rex"}, {name: "tobi"} ]
}
How can I dump dogs as an array, ie: something similar to JSON.stringify(dogs)
I tried with {#dogs}{@contextDump}{/dogs}
, but (logically) it outputs:
{"name": "rex"}{"name": "tobi"}
rather than:
["name": "rex"}, {"name": "tobi"}]
Thanks
This is possible using filters. Your template would look like this:
{dogs|js|s}
js
is basically JSON.stringify, and s
unescape everything, which will unescape the quotes in the JSON.
See this jsFiddle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With