Edgewall Software

Ticket #276 (new defect)

Opened 8 weeks ago

Python code in template is not executed correctly

Reported by: anonymous Owned by: cmlenz
Priority: minor Milestone: 0.5.2
Component: Template processing Version: 0.5
Keywords: python, execution, template Cc:

Description

Expected behavior: Python code in Genshi sample template below defines function "hello()" which produces <b>hello, world</b> in rendered template Erroneous result: genshi.template.eval.UndefinedError?: "tag" not defined

(I tried to use the function more() to reproduce the functionality of hello(), but it doesn't work, either, since the HTML-tags will be escaped in the output. Is there a way to avoid this?)

Sample template code:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://genshi.edgewall.org/" xmlns:xi="http://www.w3.org/2001/XInclude">
<head></head>
<body>
<?python
def hello():
    from genshi.builder import tag
    return tag.b('hello world')
def more():
    return '<strong>another greeting</strong>'
?>
<p>First one: ${hello()}</p>
<p>Second one: ${more()}</p>
</body>
</html>

Attachments

Add/Change #276 (Python code in template is not executed correctly)

Author



Change Properties
<Author field>
Action
as new
as The resolution will be set. Next status will be 'closed'
to The owner will change from cmlenz. Next status will be 'new'
The owner will change from cmlenz to anonymous. Next status will be 'assigned'
 
Note: See TracTickets for help on using tickets.