core.layout
Attributes
Classes
Contains useful methods related to rendering pages in html. Think of it |
|
Extends the base layout class with methods related to chameleon |
Module Contents
- class core.layout.Layout(model: Any, request: core.request.CoreRequest)[source]
Contains useful methods related to rendering pages in html. Think of it as an API that you can rely on in your templates.
The idea is to provide basic layout functions here, if they are usful for any kind of html application. You should then extend the core layout classes with your own.
- property app: core.framework.Framework[source]
Returns the application behind the request.
- batched(iterable: Iterable[_T], batch_size: int, container_factory: type[tuple] = ...) Iterator[tuple[_T, ...]] [source]
- batched(iterable: Iterable[_T], batch_size: int, container_factory: type[list]) Iterator[list[_T]]
- batched(iterable: Iterable[_T], batch_size: int, container_factory: Callable[[Iterator[_T]], Collection[_T]]) Iterator[Collection[_T]]
See
onegov.core.utils.batched()
.
- property csrf_token: str[source]
Returns a csrf token for use with DELETE links (forms do their own thing automatically).
- format_date(dt: datetime | date | None, format: str) str [source]
Takes a datetime and formats it according to local timezone and the given format.
- parse_isodate(string: str) datetime.datetime [source]
Returns the given ISO 8601 string as datetime.
- static number_symbols(locale: str) tuple[str, str] [source]
Returns the locale specific number symbols.
- format_number(number: numbers.Number | Decimal | float | None, decimal_places: int | None = None, padding: str = '') str [source]
Takes the given numer and formats it according to locale.
If the number is an integer, the default decimal places are 0, otherwise 2.
- class core.layout.ChameleonLayout(model: Any, request: core.request.CoreRequest)[source]
Bases:
Layout
Extends the base layout class with methods related to chameleon template rendering.
This class assumes the existance of two templates:
layout.pt -> Contains the page skeleton with headers, body and so on.
macros.pt -> Contains chameleon macros.
- property template_loader: core.templates.TemplateLoader[source]
Returns the chameleon template loader.
- property base: chameleon.PageTemplateFile[source]
Returns the layout, which defines the base layout of all pages.
See
templates/layout.pt
.
- property macros: core.templates.MacrosLookup[source]
Returns the macros, which offer often used html constructs. See
templates/macros.pt
.
- property elements: PageTemplate | PageTemplateFile[source]
The templates used by the elements. Overwrite this with your own
templates/elements.pt
if neccessary.