Edgewall Software

Changes between Version 6 and Version 7 of GenshiRecipes/FormFilling


Ignore:
Timestamp:
Sep 24, 2006, 7:13:18 PM (18 years ago)
Author:
cmlenz
Comment:

Add example with filter

Legend:

Unmodified
Added
Removed
Modified
  • GenshiRecipes/FormFilling

    v6 v7  
    11= [GenshiRecipes Genshi Recipes]: Automatically Populating an HTML Form =
     2
     3== Using match templates ==
    24
    35The following template provides a match template that automatically adds a `value` attribute to any `<input>` element that has matching data in the context.
     
    109111}}}
    110112
     113== Using a template filter ==
     114
     115The second, and maybe better, option, would be to use a custom template filter that filled in the form values. An example is [attachment:formfiller.py attached] to this page, and would be used like this:
     116
     117{{{
     118#!python
     119tmpl = loader.load('myform.html')
     120tmpl.filters.append(HTMLFormFiller({
     121    'name': 'Look, Ma',
     122    'enable': '',
     123    'option': 'B',
     124    'description': 'This is the description someone put in here',
     125    'dropdown': '2'
     126}))
     127print tmpl.generate().render('xhtml')
     128}}}
     129
     130That would result in the same output as above.
     131
    111132----
    112133See also: GenshiRecipes, [wiki:Documentation/xml-templates.html Genshi XML Template Language]