Edgewall Software

Opened 13 years ago

Last modified 12 years ago

#428 reopened defect

UndefinedError in py:for — at Version 2

Reported by: anonymous Owned by: cmlenz
Priority: major Milestone:
Component: Template processing Version: devel
Keywords: python3 UndefinedError Cc:

Description (last modified by cboos)

This is the code I'm running in the Python interpreter from the Documentation:

>>> from genshi.template import MarkupTemplate
>>> tmpl = MarkupTemplate('''<ul xmlns:py="http://genshi.edgewall.org/">
...   <li py:for="item in items">${item}</li>
... </ul>''')
>>> print(tmpl.generate(items=[1, 2, 3]))
<ul>
  <li>1</li><li>2</li><li>3</li>
</ul>

And I'm getting an UndefinedError for the variable item. If I force lenient mode, the template simply does not evaluate.

Change History (2)

comment:1 Changed 13 years ago by gatlin@…

I'll come clean: I formatted that poorly. Here is the relevant code again:

>>> from genshi.template import MarkupTemplate
>>> tmpl = MarkupTemplate('''<ul xmlns:py="http://genshi.edgewall.org/">
...   <li py:for="item in items">${item}</li>
... </ul>''')
>>> print(tmpl.generate(items=[1, 2, 3]))
<ul>
  <li>1</li><li>2</li><li>3</li>
</ul>

comment:2 Changed 13 years ago by cboos

  • Description modified (diff)

Works for me, Python 2.7 on Windows and Genshi 0.6 (and other combinations).

Can you please give more details about your version of Python and Genshi?

Note: See TracTickets for help on using tickets.