Changes between Version 6 and Version 7 of GenshiRecipes/FormFilling
- Timestamp:
- Sep 24, 2006, 7:13:18 PM (18 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
GenshiRecipes/FormFilling
v6 v7 1 1 = [GenshiRecipes Genshi Recipes]: Automatically Populating an HTML Form = 2 3 == Using match templates == 2 4 3 5 The following template provides a match template that automatically adds a `value` attribute to any `<input>` element that has matching data in the context. … … 109 111 }}} 110 112 113 == Using a template filter == 114 115 The 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 119 tmpl = loader.load('myform.html') 120 tmpl.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 })) 127 print tmpl.generate().render('xhtml') 128 }}} 129 130 That would result in the same output as above. 131 111 132 ---- 112 133 See also: GenshiRecipes, [wiki:Documentation/xml-templates.html Genshi XML Template Language]