Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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: Request
  • response: Response
  • l10n: L10n
  • localize: Fn(key: string, **kwargs) -> string
  • asset_url: Fn(path: string, kind: string) -> string
  • get_url: Fn(page: string, path: string, params: string, localize: bool) -> string
  • get_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
  • Request

    • locale: Locale
    • options: Map<string, string>
    • params: Map<string, string>
    • search_params: Map<string, string>

    Response

    • set_status: Fn(integer) -> None

      Function that accepts one integer argument as http status code and returns None

    L10n

    Locale

    • key: string
    • name: string

    Pagination

    • per_page: integer
    • current_page: integer
    • total_pages: integer
    • total_items: integer
    • items: List<Map<string, string>>