Json
The json
helper is used to convert a value to a JSON string; it is useful for debugging page data but can also be used to create JSON documents that can be loaded at runtime using Javascript.
Arguments
Any
The data to convert to a JSON string.
Parameters
pretty
Format the string with indentation and newlines.
Example
Pass a parameter of the data to print and optionally the pretty
hash parameter:
Which renders to:
Assuming the statement is at the top scope of a template you can print the entire page data using:
When iterating using the each
helper the this
keyword will print the current scope: