Use hugo variable in javascript

Hi, i have a shortcode shortcode.html. Is there any magic trick use the Hugo variable $test in the script tag in that shortcode like so:


{{ $test := "Hello World"  }}

<script>  
window.addEventListener("load", (event) => {
    console.log( {{ $test }} );
  });
</script>

{{/* other shortcode stuff */ -}}

Any tips welcome :slight_smile: best regards carsten

What the’s problem with the above?
Are you using the {{< >}} notation to call the shortcode?