Search code examples
javascriptgogo-html-template

How to disable escaping URL/string in an HTML template in a javascript block


I've tried to render a url as string, URL, JS and HTML. In all the cases this:

 <script>
  var someUrl = "{{ .myUrl }}";
 </script>

gets rendered to this value:

https:\/\/some_domain123.com\/path1\/path2\/path3

No matter what.

I want this:

https://some_domain123.com/path1/path2/path3

What actually works?


Solution

  • https:\/\/some_domain123.com\/path1\/path2\/path3 is the same as https://some_domain123.com/path1/path2/path3 in JavaScript.

    So, it actually works.