Part of twisted.web View Source
Class | Tag | No summary |
Class | slot | Marker for markup insertion in a template. |
Class | Comment | A <!-- --> comment from a template. Given a separate
representation in the DOM so that they may be round-tripped through
rendering without losing information. |
Class | CDATA | A <![CDATA[]]> block from a template. Given a
separate representation in the DOM so that they may be round-tripped
through rendering without losing information. |
Class | CharRef | A numeric character reference. Given a separate representation in the DOM so that non-ASCII characters may be output as pure ASCII. |
Class | TagLoader | An ITemplateLoader
that loads existing IRenderable
providers. |
Class | XMLString | An ITemplateLoader
that loads and parses XML from a string. |
Class | XMLFile | An ITemplateLoader
that loads and parses XML from a file. |
Function | renderElement | Render an element or other IRenderable . |
Class | Element | Base for classes which can render part of a page. |
Function | renderer | Decorate with renderer to use
methods as template render directives. |
Function | flatten | Incrementally write out a string representation of root
using write . |
Function | flattenString | Collate a string representation of root into a single
string. |
Class | _NSContext | A mapping from XML namespaces onto their prefixes in the document. |
Class | _ToStan | A SAX parser which converts an XML document to the Twisted STAN Document Object Model. |
Function | _flatsaxParse | Perform a SAX parse of an XML document with the _ToStan class. |
Class | _TagFactory | A factory for Tag objects; the
implementation of the tags object. |
Parameters | fl | The XML document to be parsed. (type: A file object or filename.) |
Returns | a list of Stan objects. |
IRenderable
.Parameters | request | The Request being rendered to. |
element | An IRenderable which will be rendered. | |
doctype | A str which will be written as the first line of the request,
or None to disable writing of a doctype. The
string should not include a trailing newline and will default
to the HTML5 doctype '<!DOCTYPE html>' . | |
Returns | NOT_DONE_YET | |
Present Since | 12.1 |
Decorate with renderer
to use
methods as template render directives.
For example:
class Foo(Element): @renderer def twiddle(self, request, tag): return tag('Hello, world.') <div xmlns:t="http://twistedmatrix.com/ns/twisted.web.template/0.1"> <span t:render="twiddle" /> </div>
Will result in this final output:
<div> <span>Hello, world.</span> </div>
root
using write
.
In order to create a string representation, root
will be
decomposed into simpler objects which will themselves be decomposed and so
on until strings or objects which can easily be converted to strings are
encountered.
Parameters | request | A request object which will be passed to the render method of
any IRenderable
provider which is encountered. |
root | An object to be made flatter. This may be of type unicode ,
str , slot , Tag , tuple ,
list ,
GeneratorType , Deferred , or something that
provides IRenderable . | |
write | A callable which will be invoked with each str produced by
flattening root . | |
Returns | A Deferred which will be called back when root
has been completely flattened into write or which will be
errbacked if an unexpected exception occurs. |
root
into a single
string.
This is basically gluing flatten
to a
StringIO
and returning the results. See flatten
for the
exact meanings of request
and root
.
Returns | A Deferred which will be called back with a single string as
its result when root has been completely flattened into
write or which will be errbacked if an unexpected exception
occurs. |