How to stop html template from escaping

Viewed 4377

I have an html template where i want to insert some JavaScript code from outside of template itself. In my template data struct i have created a string field JS string and call it with {{.JS}}. The problem is that everything in browser is escaped:

newlines are \n

< and > are \u003c and \u003e

" is \"

Same symbols inside of a template are fine. If I Print my JS field into console it is also fine. I have seen some similar problems solved by using template.HTML type instead of string. In my case it does not work at all.

EDIT 1

The actual context is

<script language="JavaScript">
    var options = {
        {{.JS}}
    };
</script>
2 Answers
Related