Template API
Note: Template API is currently unstable and may change without any notice.
As templates are rendered with minijinja library, the builtin filters and tests defined in minijinja is also available to you in templates. You can use them to perform various operations.
In addition to these filters and tests, Yelken also exposes various variables and functions to let you access information about request, such as locale and path params, and load contents to display them. Starting with global context, following shows variables and functions exposed by Yelken and their types side by side.
Global
request: Requestresponse: Responsel10n: L10nlocalize: Fn(key: string, **kwargs) -> stringasset_url: Fn(path: string, kind: string) -> stringget_url: Fn(page: string, path: string, params: string, localize: bool) -> stringget_content: Fn(model: string, field: string, value: string) -> Option<Map<string, string>>get_contents: Fn(model: string, fields: List, limit: integer, offset: integer) -> List<Map<string, string>> paginate: Fn(model: string, fields: List, per_page: integer, page: integer) -> Pagination locale: Localeoptions: Map<string, string>params: Map<string, string>search_params: Map<string, string>-
set_status: Fn(integer) -> NoneFunction that accepts one integer argument as http status code and returns None
key: stringname: stringper_page: integercurrent_page: integertotal_pages: integertotal_items: integeritems: List<Map<string, string>>