Go to the latest version of this document.
search in docstrings

Search bar offers the following options:

- Term presence. The below example searches for documents that must contain “foo”, might contain “bar” and must not contain “baz”: `+foo bar -baz`
- Wildcards. The below example searches for documents with words beginning with “foo”: `foo*`
- Search in specific fields. The following search matches all objects in "twisted.mail" that matches “search”: `+qname:twisted.mail.* +search`

  Possible fields: 'name', 'qname' (fully qualified name), 'docstring', and 'kind'. Last two fields are only applicable if "search in docstrings" is enabled.

- Fuzzy matches. The following search matches all documents that have a word within 1 edit distance of “foo”: `foo~1`

Results provided by Lunr.js

# ``twisted`.`web`.`template`.`Element``

class documentation

`class Element: (source)`

Known subclasses: `twisted.web.util.FailureElement`, `twisted.web.util._FrameElement`, `twisted.web.util._SourceFragmentElement`, `twisted.web.util._SourceLineElement`, `twisted.web.util._StackElement`

Implements interfaces: `twisted.web.iweb.IRenderable`

View In Hierarchy

Base for classes which can render part of a page.

An Element is a renderer that can be embedded in a stan document and can hook its template (from the loader) up to render methods.

An Element might be used to encapsulate the rendering of a complex piece of data which is to be displayed in multiple different contexts. The Element allows the rendering logic to be easily re-used in different ways.

Element returns render methods which are registered using `twisted.web._element.renderer`. For example:

        class Menu(Element):
            @renderer
            def items(self, request, tag):
                ....

Render methods are invoked with two arguments: first, the `twisted.web.http.Request` being served and second, the tag object which "invoked" the render method.

Method | `__init__` | Undocumented
Method | `lookupRenderMethod` | Look up and return the named render method.
Method | `render` | Implement `IRenderable` to allow one `Element` to be embedded in another's template or rendering output.
Instance Variable | `loader` | The factory which will be used to load documents to return from `render`.

def __init__(self, loader=None): (source)
overridden in `twisted.web.util.FailureElement`, `twisted.web.util._FrameElement`, `twisted.web.util._SourceFragmentElement`, `twisted.web.util._SourceLineElement`, `twisted.web.util._StackElement`

Undocumented

Parameters
loader:`Optional[ITemplateLoader]` | Undocumented

def lookupRenderMethod(self, name): (source)
from `twisted.web.iweb.IRenderable`

Look up and return the named render method.

Parameters
name:`str` | Undocumented
Returns
`Callable[[Optional[IRequest], Tag], Flattenable]` | Undocumented

def render(self, request): (source)
from `twisted.web.iweb.IRenderable`

Implement `IRenderable` to allow one `Element` to be embedded in another's template or rendering output.

(This will simply load the template from the `loader`; when used in a template, the flattening engine will keep track of this object separately as the object to lookup renderers on and call `Element.renderer` to look them up. The resulting object from this method is not directly associated with this `Element`.)

Parameters
request:`Optional[IRequest]` | Undocumented
Returns
`Flattenable` | Undocumented

loader = (source)
overridden in `twisted.web.util.FailureElement`

The factory which will be used to load documents to return from `render`.