fietsboek.jinja2 module

Custom filters for Jinja2.

fietsboek.jinja2.filter_format_datetime(ctx, value)

Format a datetime according to the locale.

Parameters:
  • ctx (Context) – The jinja context, passed automatically.

  • value (datetime) – The value to format.

Return type:

str

Returns:

The formatted date.

fietsboek.jinja2.filter_format_decimal(ctx, value)

Format a decimal number according to the locale.

This uses the right thousands grouping and the right decimal separator.

Parameters:
  • ctx (Context) – The jinja context, passed automatically.

  • value (float) – The value to format.

Return type:

str

Returns:

The formatted decimal.

fietsboek.jinja2.filter_local_datetime(ctx, value)

Format a UTC datetime to show in the user’s local timezone.

This is done by embedding the UTC timestamp in the page, such that we can do some client-side magic and replace it with the time in the user’s local timezone. As a fallback value, we do apply the locale’s standard formatting, in case JavaScript is disabled - however, that will not represent the time in the user’s timezone, but in UTC.

Parameters:
  • ctx (Context) – The jinja context, passed automatically.

  • value (datetime) – The value to format.

Return type:

Markup

Returns:

The formatted date.

fietsboek.jinja2.global_embed_tile_layers(request)

Renders the available tile servers for the current user, as a JSON object.

The returned value is wrapped as a Markup so that it won’t get escaped by jinja.

Parameters:

request (Request) – The Pyramid request.

Return type:

Markup

Returns:

The available tile servers.

fietsboek.jinja2.global_list_languages(request)

Returns a list of available languages.

The first element of each tuple is the (technical) locale name, the second element is the display name.

Parameters:

request (Request) – The Pyramid request.

Return type:

list[tuple[str, str]]

Returns:

The available languages.