Formatting and formulas
Predefined filters and formulas to format the date in your template
Filters
All default jinja2 filters can be used in the template.
The following additional filters are available the template:
Not None
not_none
- Avoids to print None
in the template.
Usage: {{ any|not_none }}
Format Price
format_price
- Formats the price to x.xx \[CUR\]
e.g. 13.37 EUR
.
Usage: {{ shipment_item.price|format_price }}
A factor can be specified to calculate the price of a shipment item which has amount > 1
Usage: {{ shipment_item.price|format_price(shipment_item.amount) }}
Total Price
total_price
- Calculates total price of the shipment and formats it with format_price
.
Usage: {{ shipment|total_price }}
Format Weight
format_weight
- Formats the given weight to x.xxx kg
e.g. 1.337 kg
.
Usage: {{ shipment_item.weight|format_weight }}
A factor can be specified to calculate the weight of a shipment item which has amount > 1
Usage: {{ shipment_item.weight|format_weight(shipment_item.amount) }}
Total Weight
total_weight
- Calculates total weight of the shipment and formats it with format_weight
.
Usage: {{ shipment|total_weight }}
Format Street
format_street
- Formats the street name, house number and addition of the address e.g. Fakestreet 1337, Fakeaddition
.
Usage: {{ sender_address|format_street }}
Format Country
format_country
- Formats the country to CC - CountryName
e.g. DE - GERMANY
.
Usage: {{ sender_address.country|format_country }}
Format Customer Name
format_customer_name
- Formats the customer name.
Usage: {{ customer|format_customer_name }}
Order of formatting (if not provided, next is used).
customer.senderName
customer.companyName
customer.firstName
andcustomer.lastName
Globals
All default jinja2 globals can be used in the template.
The following additional methods are available in the template:
current_date
- Formats localdatetime.now()
with the given format.
Usage:{{ current_date("%d.%m.%Y") }}
Tests
All default jinja2 tests can be used in the template.
The following additional tests are available in the template:
-
gift
- Checks if the shipment is typegift
.
Usage:{% if shipment is gift %}
-
document
- Checks if the shipment is typedocument
.
Usage:{% if shipment is document %}
-
sample
- Checks if the shipment is typesample
.
Usage:{% if shipment is sample %}
-
remand
- Checks if the shipment is typeremand
.
Usage:{% if shipment is remand %}
-
other
- Checks if the shipment is typeother
.
Usage:{% if shipment is other %}
Updated over 1 year ago