safeHTML inside <script> tags

how can I use safeHTML function inside tags without converting “<” to “\u003c” or “\x3c” and “>” to “\u003e” or “\x3e”

like this

{{$test := "<div>Hello</div>"}}

{{ safeHTML $test }}
<script>
{{ safeHTML $test }}
"{{ safeHTML $test }}"
</script>

turns to this

<div>Hello</div>
<script>
"\u003cdiv\u003eHello\u003c/div\u003e"
"\x3cdiv\x3eHello\x3c\/div\x3e"
</script>

I just need to keep the tags just like when it’s outside tags

I can’t reproduce your output. Please share a repo that shows your output. :slight_smile:

the file is in https://gitlab.com/emandeguzman/safehtml-in-script/-/blob/master/layouts/shortcodes/sample.html

1 Like