XYAPTU is an ASPN recipie based on YAPTU. Both modules are included with the web modules and can be imported directly:
import web import xyaptu, yaptu
Here is an example xyaptu template:
<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>$title</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <p>$welcomeMessage</p> <py-open code="if testVar:" /> The variable is: True <py-clause code="else:" /> The variable is: False <py-close/> </body> </html>
Here is a program to manipulate it:
#!/usr/bin/env python import sys; sys.path.append('../../../') # show python where the web modules are import web.template dict = { 'welcomeMessage':'Welcome to the test page!', 'testVar':True, 'title':'XYAPTU Example', } print web.template.parse( type='xyaptu', file='file-web-template-xyaptu.tmpl', dict=dict )
And here is the output produced:
<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>XYAPTU Example</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <p>Welcome to the test page!</p> The variable is: True </body> </html>
See Also: