ui icon indicating copy to clipboard operation
ui copied to clipboard

Allow verbatim (non-html encoded strings) in templates

Open endeavour opened this issue 8 years ago • 1 comments

It would be useful to be able to insert verbatim strings into templated documents, particularly for inserting javascript directly.

At the moment, if I add a hole as follows: <script type="text/javascript"> ${myScript} </script>

And then set myScript="""alert('hello world');""", it doesn't work as expected because the string gets HTML encoded.

Perhaps a new type of hole could be declared to support this scenario.

endeavour avatar Apr 16 '16 10:04 endeavour

I'm not sure whether adding a non HTML encoded string hole is a good idea but you can do this with the current templating:

<script type="text/javascript"><div data-replace="myScript"></div></script>
myScript=[Doc.Verbatim """alert('hello world');"""]

qwe2 avatar Apr 17 '16 13:04 qwe2

Closing, just use Doc.Verbatim as described in @qwe2 's comment.

granicz avatar Oct 18 '22 02:10 granicz