Edgewall Software

Ticket #276 (closed defect: fixed)

Opened 3 years ago

Last modified 2 years ago

Python code in template is not executed correctly

Reported by: anonymous Owned by: cmlenz
Priority: minor Milestone: 0.6
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

Change History

Changed 3 years ago by cmlenz

  • status changed from new to assigned

Changed 3 years ago by cmlenz

  • status changed from assigned to closed
  • resolution set to fixed

Should be fixed by [1008], and ported to 0.5.x in [1010].

Changed 2 years ago by cmlenz

  • milestone changed from 0.5.2 to 0.6

Milestone 0.5.2 deleted

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

Author


E-mail address and user name can be saved in the Preferences.


Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.