I have a template which is included from several other templates. I am passing in some data, and I want to dynamically create some javascript in each page.
I have the following in each template
<canvas id="{{.Id}}"></canvas>
<script type='application/ld+json'>
const {{ .Id }} = new Chart(document.getElementById({{.Id}})
...
I expect to create something like this
<canvas id="someName"></canvas>
<script type='application/ld+json'>
const someName = new Chart(document.getElementById(someName)
...
but instead, I get this
<canvas id="someName"></canvas>
<script type='application/ld+json'>
const "someName" = new Chart(document.getElementById("someName")
...
After looking this up, apparently golang makes an attempt to add characters to my string out on my-behalf when it detects the 'script' tag. Obviously the true context of what I am doing is not understood by this feature. Is there any way to get around this 'helper feature', or even better, a way to disable this completely?