Skip to content

Commit fa30b85

Browse files
docs: adding documentation for template filters and tags for flag_is_active, switch_is_active, sample_is_active
1 parent 682f730 commit fa30b85

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

docs/usage/templates.rst

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,51 @@ Samples
6767
{% endsample %}
6868

6969

70+
Django Template Filters and Tags
71+
================================
72+
Django Waffle provides three new Django Template tags and filters, ``flag_is_active``,
73+
``switch_is_active``, and ``sample_is_active``. Each of these tags and filters can be used in Django
74+
template's if statement contitions to check if a flag, switch, or sample is active.
75+
76+
This is useful for when a django template context variable and a flag, switch, or sample are required to
77+
be active in order to render a certain part of the template.
78+
79+
flag_is_active
80+
--------------
81+
82+
::
83+
84+
{% flag_is_active "flag" request True as is_flag_active %}
85+
{% if is_flag_active %}
86+
flag_is_active on
87+
{% else %}
88+
flag_is_active off
89+
{% endif %}
90+
91+
switch_is_active
92+
----------------
93+
94+
::
95+
96+
{% if "switch"|switch_is_active %}
97+
switch_is_active on
98+
{% else %}
99+
switch_is_active off
100+
{% endif %}
101+
102+
sample_is_active
103+
----------------
104+
105+
::
106+
107+
{% if "sample"|sample_is_active %}
108+
sample_is_active on
109+
{% else %}
110+
sample_is_active off
111+
{% endif %}
112+
113+
114+
70115
.. _templates-jinja:
71116

72117
Jinja Templates

0 commit comments

Comments
 (0)