[Greasemonkey] Long literal strings of html

Julien Couvreur julien.couvreur at gmail.com
Wed Apr 13 09:33:45 EDT 2005

Perl uses a trick to store unescaped content at the end of the script,
after the __DATA__ token. It's called SelfLoader
(http://www.perl.com/doc/manual/html/lib/SelfLoader.html ).

Question: is there any similar trick in javascript that would allow
putting long strings without having to care about escaping them?
One way I'd to use such a text blob is like JSP: you mix in HTML and
code, the whole thing gets converted into code (with Response.Write
for the chunks of HTML) for you. That could be useful for those who
are inserting more than a few lines of HTML?

Another approach would be to offer a script editor (XUL or HTML/JS?),
but that seems much more difficult...
In my script generator page, the idea was the same: you let the user
input plain HTML (without caring about escaping) that allows special
tokens (that will be replaced by variable values, namely the href of
the link being processed). The script generation takes care of
escaping the string.


More information about the Greasemonkey mailing list