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: - value – datetime object
- format_string – ‘PHP format string <https://www.php.net/manual/en/datetime.format.php>’_
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
SideBar¶
-
sidebar() → list Get the sidebar object
Returns: List of sidebar objects [ { 'category': 'item', 'value': 'value?', 'active': True, 'path': 'path:to:page' 'login_required': False, # Item Type 'item': True, 'header': False, 'divider': False }, { 'item': False, 'header': True, 'divider': False }, { 'item': False, 'header': False, 'divider': True } ]
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