End in non-text context Error

Hi, I have this new error although I’ve been using Hugo fine for a few years. I guess my shortcode broke during an update but I don’t know the cause.

Error msg:faiiled to render shortcode "nanogallery": failed to process shortcode: execute of template failed: html/template:shortcodes/nanogallery.html: ends in a non-text context: {stateJS delimNone urlPartNone jsCtxRegexp attrNone elementScript <nil>} Error: Process completed with exit code 1.

nanogallery.html:

 nanogallery.html                                                                                                                     buffers 
<!-- configfile can be an absolute path or page relative -->    
{{ $configFilePath := ( .Get "configfile" ) }}    
{{ if not ( hasPrefix ( .Get "configfile" ) "/" ) }}    
{{ $configFilePath = print $.Page.File.Dir $configFilePath }}    
{{ end }}    
    
{{ $contentFilePath := print $.Page.File.Dir ( .Get "contentfile" ) }}    
{{ $galId := .Get "id" | default "gallery" }}    
    
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"/>    
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>    
<link href="https://cdnjs.cloudflare.com/ajax/libs/nanogallery2/3.0.5/css/nanogallery2.min.css" rel="stylesheet" type="text/css" />    
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/nanogallery2/3.0.5/jquery.nanogallery2.core.min.js"></script>    
<div id="{{ $galId }}"></div>    
    
<script><!--    
$(document).ready(function () {    
  $("#{{ $galId }}").nanogallery2({    
{{ $configFilePath | readFile | safeJS }}    
   items:    
{{ $contentFilePath | readFile | safeJS }}    
  });    
 });    
--></script>  ```

Thanks for the help

I’m also having issues with Hugo since the 119 update for any page which includes javascript in it. Both the non-text context error, and other errors where Hugo mis-identies sections of the site as being a JS template literal when its not.

See https://discourse.gohugo.io/t/0-119-regression-in-html-parsing/46397/2