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.diff_json(a, b)[source]
promgen.templatetags.promgen.klass(value)[source]
promgen.templatetags.promgen.pretty_json(data)[source]
promgen.templatetags.promgen.pretty_yaml(data)[source]
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.rule_dict(rule)[source]
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]
promgen.templatetags.promgen.urlqs(view, **kwargs)[source]

Query string aware version of url template

Instead of using {% url ‘view’ %} Use {% urlqs ‘view’ param=value %}

This is useful for linking to pages that use filters. This only works for views that do not need additional parameters