Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

227
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda