Add paragraph about mixing HTML and plain templates [...] (quixote/doc/PTL.txt)
Andrew Kuchling <akuchlin-fVcApmY9cLvQ3/1i3zOLAti2O/[email protected]> Tue, 07 Jan 2003 11:27:50 -0500
| Newsgroups | gmane.comp.web.quixote.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /home/cvs/quixote/doc In directory hewson:/tmp/cvs-serv18484 Modified Files: PTL.txt Log Message: Add paragraph about mixing HTML and plain templates (I'm not happy with the text; please rewrite or offer suggestions) Fix a typo. Index: PTL.txt =================================================================== RCS file: /home/cvs/quixote/doc/PTL.txt,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- PTL.txt 6 Jan 2003 20:14:34 -0000 1.16 +++ PTL.txt 7 Jan 2003 16:27:48 -0000 1.17 @@ -161,7 +161,7 @@ once. While ``htmltext`` behaves much like a regular string, it is sometimes necessary to insert a ``str()`` inside a template in order to obtain a genuine string. For example, the ``re`` module requires -genuine strings. We have found that explict calls to ``str()`` can +genuine strings. We have found that explicit calls to ``str()`` can often be avoided by splitting some code out of the template into a helper function written in regular Python. @@ -208,6 +208,14 @@ Note how the title and description have had HTML-escaping applied to them. (The output has been manually pretty-printed to be more readable.) + +Once you start using ``htmltext`` in one of your templates, mixing +plain and HTML templates is tricky because of ``htmltext``'s automatic +escaping; plain templates that generate HTML tags will be +double-escaped. One approach is to just use HTML templates throughout +your application. Alternatively you can use ``str()`` to convert +``htmltext`` instances to regular Python strings; just be sure the +resulting string isn't HTML-escaped again. PTL modules