Using without qpy and still doing html quoting

Qpy is only used when quoting="xml", thus if you run with quoting="str" you will not need to have Qpy installed, but you will need to take care of quoting yourself. As an example, let's use the code from the the evoque_mq benchmark that is included in the distribution:

First, make quoting="str" the domain-wide default, and we can also set, on the domain's globals, the quoting function we want to use:

import evoque from os.path import abspath, join, dirname DIR = abspath(join(dirname(evoque.__file__), 'bench/evoque')) from evoque.domain import Domain domain = Domain(DIR, quoting="str") import cgi domain.set_on_globals("quote", cgi.escape)

Specify the actual quoting in the template itself, template_mq.html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <title>${quote(title)}</title> </head> <body> $evoque{header_mq.html} $begin{greeting}Hello, ${quote(you)}!$end{greeting} <div>$evoque{#greeting, you=user}</div> <div>$evoque{#greeting, you="me"}</div> <div>$evoque{#greeting, you="world"}</div> <h2>Loop</h2> $if{items}<ul> $for{idx, item in enumerate(items)}\ #[ $if{ idx+1 == len(items) } class="last"$fi ]# <li${idx+1==len(items) and " class='last'" or ""}>${ quote(item)}</li> $rof </ul>$fi $evoque{footer.html} $test{ title='Just a test', user='joe', items=['a', '<b/>', 'c'] } </body> </html>

Rendering is as usual:

data = dict(title="Just a test", user="joe", items=["<n>%d</n>" % (num) for num in range(1, 15)]) domain.get_template("template_mq.html").evoque(data)