html/template
has a very convenient feature. If I have a template like this:
<html>
...
<script>var x = '{{ .Data }}';</script>
...
</html>
The variable Data
can be of any type, and html/template
converts it to JSON. For example:
<html>
...
<script>var x = '{"nombre":"José","edad":32}';</script>
...
</html>
My question is: Is it possible to use different options for the JSON format? I would like, for example, to use json.MarshalIndent()
to make the template output easier to read.