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 compatiable breadcrumb

promgen.templatetags.promgen.diff_json(a, b)[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.qsfilter(request, k, v)[source]

Helper to rewrite query string for URLs

{% qsfilter request ‘foo’ ‘baz’ %} When passed the request object, it will take a querystring like ?foo=bar&donottouch=1 and change it to ?foo=baz&donottouch=1

Useful when working with filtering on a page that also uses pagination to avoid losing other query strings {% qsfilter request ‘page’ page_obj.previous_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]