.. -*- mode: rst; encoding: utf-8 -*- ============== Stream Filters ============== `Markup Streams`_ showed how to write filters and how they are applied to markup streams. This page describes the features of the various filters that come with Genshi itself. .. _`Markup Streams`: streams.html .. contents:: Contents :depth: 1 .. sectnum:: HTML Form Filler ================ The filter ``genshi.filters.html.HTMLFormFiller`` can automatically populate an HTML form from values provided as a simple dictionary. When using this filter, you can basically omit any ``value``, ``selected``, or ``checked`` attributes from form controls in your templates, and let the filter do all that work for you. ``HTMLFormFiller`` takes a dictionary of data to populate the form with, where the keys should match the names of form elements, and the values determine the values of those controls. For example: .. code-block:: pycon >>> from genshi.filters import HTMLFormFiller >>> from genshi.template import MarkupTemplate >>> template = MarkupTemplate("""
...

...
...
... ...

...
""") >>> filler = HTMLFormFiller(data=dict(username='john', remember=True)) >>> print(template.generate() | filler)



.. note:: This processing is done without in any way reparsing the template output. As any stream filter it operates after the template output is generated but *before* that output is actually serialized. The filter will of course also handle radio buttons as well as ``