def loop (items) : s = [] if items: num_items = len(items) class_attr = "" s.append(xml('<ul>')) for i, item in enumerate(items): if i+1 == num_items: class_attr = ' class="last"' s.append(xml('<li'+class_attr+'>')) s.append(item) s.append(xml('</li>\n')) s.append(xml('</ul>')) return xml("").join(s)
def loop(items): s = [] if items: num_items = len(items) class_attr = "" s.append(xml('<ul>')) for i, item in enumerate(items): if i + 1 == num_items: class_attr = ' class="last"' s.append(xml('<li' + class_attr + '>')) s.append(item) s.append(xml('</li>\n')) s.append(xml('</ul>')) return xml("").join(s)
def test_xml_automatic_quoting(self): if not xml: return td = Domain(DEFAULT_DIR, restricted=RESTRICTED, errors=ERRORS, quoting="xml") name = "template.html#label" t = td.get_template(name) self.failUnless(xml is t.qsclass) self.failUnless(xml is t.evoque(title="xml", param="<xml/>").__class__) self.assertEqual(self.r_xml_escaped, t.evoque(title="q-xml", param="<in>rm *</in>")) r = "<h1>q-xml</h1><p>some <in>rm *</in> text</p>" self.assertEqual(r, t.evoque(title="q-xml", param=xml("<in>rm *</in>")))
def test_qpy_list_append(): b = [] w = b.append table = ctx['table'] w(xml(u'<table>\n')) for row in table: w(xml(u'<tr>\n')) for key, value in row.items(): w(xml(u'<td>')) w(xml_quote(key)) w(xml(u'</td><td>')) w(value) w(xml(u'</td>\n')) w(xml(u'</tr>\n')) w(xml(u'</table>')) return join_xml(b)
def test_qpy_list_append() -> str: b: typing.List[str] = [] w = b.append table = ctx["table"] w(xml("<table>\n")) for row in table: w(xml("<tr>\n")) for key, value in row.items(): w(xml("<td>")) w(xml_quote(key)) w(xml("</td><td>")) w(str(value)) w(xml("</td>\n")) w(xml("</tr>\n")) w(xml("</table>")) return join_xml(b)
def header(title): return xml('<div id="header"><h1>') + title + xml('</h1></div>')
def greeting(name): return xml('Hello ') + name + xml('!')
__url__ = "$URL: svn://gizmojo.org/pub/evoque/trunk/bench/qpy_eval/templates.py $" __revision__ = "$Id: templates.py 1135 2009-01-10 16:42:30Z mario $" import sys from qpy import xml def greeting(name): return xml('Hello ') + name + xml('!') def header(title): return xml('<div id="header"><h1>') + title + xml('</h1></div>') footer = xml('<div id="footer"></div>') def loop(items): s = [] if items: num_items = len(items) class_attr = "" s.append(xml('<ul>')) for i, item in enumerate(items): if i + 1 == num_items: class_attr = ' class="last"' s.append(xml('<li' + class_attr + '>')) s.append(item) s.append(xml('</li>\n')) s.append(xml('</ul>'))
def header(title): return xml('<div id="header"><h1>') +title+ xml('</h1></div>')
def greeting(name): return xml('Hello ') +name+ xml('!')
Licensed under the Academic Free License version 3.0 URL: http://evoque.gizmojo.org/ ''' __url__ = "$URL: svn://gizmojo.org/pub/evoque/trunk/bench/qpy_eval/templates.py $" __revision__ = "$Id: templates.py 1135 2009-01-10 16:42:30Z mario $" import sys from qpy import xml def greeting(name): return xml('Hello ') +name+ xml('!') def header(title): return xml('<div id="header"><h1>') +title+ xml('</h1></div>') footer = xml('<div id="footer"></div>') def loop (items) : s = [] if items: num_items = len(items) class_attr = "" s.append(xml('<ul>')) for i, item in enumerate(items): if i+1 == num_items: class_attr = ' class="last"' s.append(xml('<li'+class_attr+'>')) s.append(item) s.append(xml('</li>\n')) s.append(xml('</ul>')) return xml("").join(s)