= [GenshiRecipes Genshi Recipes]: Automatically Populating an HTML Form = The goal is to automatically add a `value` attribute to any `` element with the appropriate data, and similar for other kinds of form controls. Assume the following template defining a simple form: {{{ #!genshi

Select one:

}}} == Using a Stream Filter == The best option is to use the Genshi [wiki:Documentation/filters.html#html-form-filler HTMLFormFiller] stream filter that fills in form values. {{{ #!python tmpl = loader.load('myform.html') fill = HTMLFormFiller(data={ 'name': 'Look, Ma', 'enable': 'on', 'option': 'B', 'description': 'This is the description someone put in here', 'dropdown': '2' }) print tmpl.generate().filter(fill).render('html') }}} The output would look as follows: {{{ #!text/html

Select one:

}}} == Using Match Templates == The following template provides a match template that automatically adds a `value` attribute to any `` element that has matching data in the context. {{{ #!genshi …