0

I want to embed JSON in the DOM as outlined in the below question:

Best practice for embedding arbitrary JSON in the DOM?

However I can't figure out how to do this with Scalate/Scalatra. I have this in my scaml template:

-@ val fullStateJson: String

and I can render it via

%div= fullStateJson

but I can't figure out how to get this into a <script>. When I do

%script(type="application/json" id="fullStateScript") =fullStateJson

It ends up escaped, like

{&quot;45&quot;:{&quot;id&quot;:45,&quot;level&quot;:0},&quot;98&quot;:{&quot;id&quot;:98,&quot;level&quot;:0}}
Community
  • 1
  • 1
scalapeno
  • 833
  • 1
  • 6
  • 13

1 Answers1

1

The TemplateEngine.escapeMarkup is set to true by default, so it changes the html special characters.

You can put this in your template: <% escapeMarkup = false %>