API Docs¶
Jinja utilities for Invenio.
-
class
invenio_formatter.ext.
InvenioFormatter
(app=None)[source]¶ Invenio-Formatter extension.
Extension initialization.
Parameters: app – The Flask application. (Default: None
)
Context preprocessors¶
Badges context processor.
-
invenio_formatter.context_processors.badges.
badges_processor
()[source]¶ Context processor for badges.
-
invenio_formatter.context_processors.badges.
generate_badge_png
(title, value, color='#007ec6')[source]¶ Generate the badge in PNG format.
Filters¶
Datetime Jinja filters.
-
invenio_formatter.filters.datetime.
format_arrow
(value, format_string)[source]¶ Format an arrow datetime object.
Parameters: - value – The arrow datetime object.
- format_string – The date format string
Returns: Returns a string representation of the given arrow datetime object, formatted according to the given format string.
Note
Do not use this filter to format date/times presented to an end user. Instead use
datetimeformat
ordateformat
from Invenio-I18N.
-
invenio_formatter.filters.datetime.
from_isodate
(value, strict=False)[source]¶ Convert an ISO formatted date into a Date object.
Parameters: - value – The ISO formatted date.
- strict – If value is
None
, then if strict isTrue
it returns the Date object of today, otherwise it returnsNone
. (Default:False
)
Returns: The Date object or
None
.
-
invenio_formatter.filters.datetime.
from_isodatetime
(value, strict=False)[source]¶ Convert an ISO formatted datetime into a Date object.
Parameters: - value – The ISO formatted datetime.
- strict – If value is
None
, then if strict isTrue
it returns the Date object of today, otherwise it returnsNone
. (Default:False
)
Returns: The Date object or
None
.
-
invenio_formatter.filters.datetime.
to_arrow
(value)[source]¶ Convert a Date object to an arrow datetime object.
HTML sanitisation Jinja filters.
-
invenio_formatter.filters.html.
sanitize_html
(value, tags=None, attributes=None)[source]¶ Sanitize HTML.
Parameters: - tags – Allowed HTML
tags
. Configuration set by Invenio-Config. - attributes – Allowed HTML
attributes
. Configuration set by Invenio-Config.
Use this function when you need to include unescaped HTML that contain user provided data.
- tags – Allowed HTML