Inner with native text in shortcode

Hello,

I try to create a JavaScript based shortcode e.g.

<script>
       jQuery(function() {

            var obj = { {{- .Inner -}}  }

       });
</script>

If I run the shortcode within the markdown file with

{{< js >}}
       foo : "bar",
       num : 123
{{< /js >}}

of with

{{% js %}}
       foo : "bar",
       num : 123
{{% /js %}}

Hugo quotes the inner content to

"foo : \"bar\",\nnum : 123"

and my JSON object does not work anymore. So how can I tell Hugo that the inner content of the shortcode should be exactly put into the HTML content without any adding anything, so is there something like .RawInner ?

Thanks
Phil

Go templates are context aware and escape strings for security reasons, e.g. those from external sources that you can’t control.

But since the content is coming from a trustworthy source you could try to mark it as safe with the safeJS template function:

<script>
       jQuery(function() {

            var obj = { {{- .Inner | safeJS -}}  }

       });
</script>

Thanks, I have tried it with safeHTML, but this does not work, so it was my mistake, I will use JavaScript so thanks for the tip with safeJS, this works fine