Templates

The template system uses jinja2 and there are several custom commands added that you can use.

You can find all the function definitions in blueweather.jinja2

Static

static(static_file: str) → str

Find the url path for a static file.

Parameters:static_file – static file path
Returns:url path for the static file

Url

url(pattern: str) → str

Get the url from a url pattern.

Parameters:

pattern – url pattern

Returns:

url

Example:
>>> url("api:simplePlugin:apiName")
/api/simpleplugin/apiname

Time

time(value, format_string: str) → str

Format a datetime object into a format_string

Parameters:
Returns:

formatted datetime string

Example:
>>> time(now(), "Y-m-d H:i:s")
2020-08-30 12:00:32

Now

now() → datetime.datetime

Get the current time as a datetime object

Returns:time

Number

number(number: float) → str

Format a number using localization Settings

Parameters:

number – the number to localize

Returns:

localized number string

Example:
>>> number(1000)
1,000

Add_attrs

blueweather.jinja2.add_attrs(widget: django.forms.widgets.Widget, attr, *args)

Add css classes to a widget

Parameters:
  • widget – widget to add classes
  • args – space separated classes

Set_attr

blueweather.jinja2.set_attr(widget, attr, value)

Add values to an attr of a widget

Parameters:
  • widget – widget to add to
  • atr (str) – name of attribute
  • value – value

Add_classes

blueweather.jinja2.add_classes(widget, *args)

Add css classes to a widget

Parameters:
  • widget – widget to add classes
  • args – space separated classes

Get_or_call

blueweather.jinja2.get_or_call(request, setting)