# HG changeset patch # User cmlenz # Date 1175538063 0 # Node ID 6fd7e4dc031817e5dc9c07a839067d957fa37221 # Parent 3d82c5bdbf466383e63136a921042cb9b04469b4 Added documentation page on the builtin stream filters. diff --git a/MANIFEST.in b/MANIFEST.in --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,4 +2,5 @@ exclude doc/docutils.conf recursive-exclude doc/logo.lineform * exclude doc/Makefile +include doc/api/*.* include doc/*.html diff --git a/doc/epydoc.conf b/doc/epydoc.conf --- a/doc/epydoc.conf +++ b/doc/epydoc.conf @@ -18,7 +18,7 @@ # HTML output output: html target: doc/api/ -css: doc/style/apidoc.css +css: doc/style/epydoc.css top: genshi frames: no sourcecode: no diff --git a/doc/filters.txt b/doc/filters.txt new file mode 100644 --- /dev/null +++ b/doc/filters.txt @@ -0,0 +1,132 @@ +.. -*- 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.HTMLFormFiller`` can automatically populate an HTML +form from values provided as a simple dictionary. When using thi 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:: + + >>> 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 ``