liara.template
¶
Module Contents¶
Classes¶
Jinja2 based template repository. |
|
A wrapper around |
|
A wrapper around |
API¶
- class liara.template.Template(template_path='<unknown>')¶
Bases:
abc.ABC
- property path¶
- abstract render(**kwargs) str ¶
- class liara.template.TemplateRepository(paths: Dict[str, str])¶
Bases:
abc.ABC
- update_paths(paths: Dict[str, str])¶
- abstract find_template(url: pathlib.PurePosixPath, site: liara.Site) liara.template.Template ¶
- class liara.template.MakoTemplate(template, template_path)¶
Bases:
liara.template.Template
- render(**kwargs) str ¶
- class liara.template.MakoTemplateRepository(paths: Dict[str, str], path: pathlib.Path)¶
Bases:
liara.template.TemplateRepository
- find_template(url: pathlib.PurePosixPath, site: liara.Site) liara.template.Template ¶
- class liara.template.Jinja2Template(template, template_path)¶
Bases:
liara.template.Template
- render(**kwargs) str ¶
- class liara.template.Jinja2TemplateRepository(paths: Dict[str, str], path: pathlib.Path, cache: Optional[liara.cache.Cache] = None, *, options: Optional[Dict[str, Any]] = None)¶
Bases:
liara.template.TemplateRepository
Jinja2 based template repository.
Initialization
- find_template(url: pathlib.PurePosixPath, site: liara.Site) liara.template.Template ¶
- class liara.template.Page(node)¶
A wrapper around
DocumentNode
andIndexNode
for use inside templates.Templates only get applied to those node types, and the
Page
class provides convenience accessors while hiding the underlying node from template code.Initialization
- property content: str¶
Provides the content of this page.
- property url: str¶
Provides the current path of this page.
- property meta: types.MappingProxyType[str, Any]¶
Provides the metadata associated with this page.
Deprecated since version 2.1.2: Use
metadata
instead.Changed in version 2.6.2: Made read-only
- property metadata: types.MappingProxyType[str, Any]¶
Provides the metadata associated with this page.
Added in version 2.1.2.
Changed in version 2.6.2: Made read-only
- property references: liara.query.Query¶
Provides the list of referenced nodes by this page.
This can be only used if the current page is an
IndexNode
, in all other cases this will fail. For index nodes, this will return the list of references as aQuery
instance.
- property children: liara.query.Query¶
Return all child pages of this page, i.e. document and index nodes.
Added in version 2.4.
- class liara.template.SiteTemplateProxy(site: liara.Site)¶
A wrapper around
Site
for use inside templates.Initialization
- property data: types.MappingProxyType[str, Any]¶
Get the union of all
liara.nodes.DataNode
instances in this site.Changed in version 2.6.2: Made read-only Before 2.6.2, this dictionary could be modified, but that was always an unsafe operation.
- property metadata: types.MappingProxyType[str, Any]¶
Provide access to the metadata of this site.
Changed in version 2.6.2: Made read-only Before 2.6.2, this dictionary could be modified, but that was always an unsafe operation.
- select(query) liara.query.Query ¶
Run a query on this site. Returns any node matching the query.
- select_pages(query) liara.query.Query ¶
Run a query on this site and return only matching pages, i.e. document and index nodes.
Added in version 2.4.
- get_page_by_url(url) Optional[liara.template.Page] ¶
Return a page by URL. If the page cannot be found, return
None
.
- get_previous_in_collection(collection: str, page: liara.template.Page) Optional[liara.template.Page] ¶
Given a collection and a page, return the previous page in this collection or
None
if this is the first page.
- get_next_in_collection(collection: str, page: liara.template.Page) Optional[liara.template.Page] ¶
Given a collection and a page, return the next page in this collection or
None
if this is the last page.
- get_collection(collection: str) liara.query.Query ¶
Get a collection in form of a
liara.query.Query
for further filtering/sorting.