Template Tags¶
- promgen.templatetags.promgen.breadcrumb(instance=None, label=None)[source]¶
Create HTML Breadcrumb from instance
Starting with the instance, walk up the tree building a bootstrap3 compatible breadcrumb
- promgen.templatetags.promgen.qs_replace(context, k, v)[source]¶
Query string handler for paginators
Assuming we have a query string like ?page=1&search=foo, there are several cases in which we want to replace only the page key, while leaving the rest alone. This tag allows us to replace individual values (like the current page) while carrying over other values (like a search string)
Example: {% qs_replace ‘page’ page_obj.next_page_number %}
- promgen.templatetags.promgen.rulemacro(rule, clause=None)[source]¶
Macro rule expansion
Assuming a list of rules with children and parents, expand our macro to exclude child rules
Can optionally pass expression to render in the context of the passed rule
foo{<exclude>} / bar{<exclude>} > 5 # Parent Rule foo{project="A", <exclude>} / bar{project="A", <exclude>} > 3 # Child Rule foo{project="B"} / bar{project="B"} > 4 # Child Rule foo{project~="A|B"} / bar{project~="A|B"} > 5 foo{project="A", } / bar{project="A"} > 3 foo{project="B"} / bar{project="B"} > 4
- promgen.templatetags.promgen.strftime(timestamp, fmt)[source]¶
Convert a timestamp to a specific format.
Normally we would use the built in django time filters, but sometimes we get a numeric value as a timestamp (from Prometheus results) so we want a single place where we can convert any type of value to a timestamp.