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}} 

1 Answer 1

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 %>

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.