However all other templates referencing the same URL render perfectly fine, it’s seemingly only templates that are inside the <script> tag that have the issue. And no amount of | safeURL etc seems to fix the issue.
Also nested structured data templates are rendering with newline characters intact (so the entire template in a single line with \n characters).
That works for the specific case of an inline URL, but doesn’t seem to work at all for nested structured data, while piping the top level partial through safeJS does seem to work.
I don’t see any nesting within that topic, at least not like I’m doing where there’s an embedded partial call that brings in another bit of structured data that itself might have URLS.
If I use the above trick to fix the URL the resulting partial still comes back all in a single line with newlines intact. If I mark the partial call as safeJS then it’s no longer in a single line, but it’s full of improperly encoded characters and the URL is screwed up again.
Only if I do not apply the | jsonify | safeJS fix to any of the partials, remove the <script> tags to the root template, and then mark the partial call that builds the whole nested JSON-LD tree and pipes it through safeJS do I get a properly rendered structure.