Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

218
Vistas
golang, how to disable autoscape in templates

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?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda