I’m trying to add some schema.org data to a page. Specifically, I am trying to add a baseSalary value which is required to be the format100000.00 (as a float with 2-decimal precision).
In the front matter I’m storing this information as an int, i.e. 100000. I can’t figure out how to get this to render as 100000.00 in the template.
In full context: "value": {{- .Params.base_salary -}}.00, --> "value": 100000 .00,
Because this is invalid JSON, the site won’t build:
Error building site: failed to render pages: JSON parse error: expected comma character or an array or object ending on line 33 and column 25
33: "value": 100000 .00,
I saw, but not the original frontmatter. Just what came out of it.
The space in {{ .Params.base_salary -}}.00 doesn’t make much sense in a templating way.
jsonifyreturns a template.HTML type. The string would still be quoted by the template engine, which wants a template.JS type in a JSON context.
Additionally, jsonify calls the JSON marshaller, which is considerably heavier than what safeJS is doing. safeJS is essentially a type cast, which is really all you need here to satisfy the template engine’s security model.