Open main menu

Wikibooks β

Karrigell/Insert dynamic values in a template

< Karrigell

The templating system uses Python string formatting

Create a template called page.tmpl :

Hello {name}

then edit and add this function :

def bar(name):
    return Template('page.tmpl',title='template test',name=name)

Enter http://localhost/ to see how the templating engine replaced the placeholders {title} and {name} by the values passed to the function Template