ui
ui copied to clipboard
Allow verbatim (non-html encoded strings) in templates
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.
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');"""]
Closing, just use Doc.Verbatim
as described in @qwe2 's comment.