Hi,
How can I display an object with all its keys and values in Blaze?
In angular I can do
{{currentUser | json}}
Thanks,
Hi,
How can I display an object with all its keys and values in Blaze?
In angular I can do
{{currentUser | json}}
Thanks,
Couldn’t you just make a global template helper called json
which does JSON.parse
?
Template.registerHelper('json', function (object) {
return JSON.parse(object);
});
Then use it like so:
{{json currentUser}}
Where is the correct place to define global template helpers?
Template.registerHelper(‘json’, function (object) {
return JSON.stringify(object);
});
Wherever you want!
I’ve got mine in /imports/startup/client/templateHelpers.js
for a large app.
And just stick them in /client/main.js
for small apps.
Structure helps you for large apps, don’t worry too much if it’s a small one