Skip to content

Feature request: Add template filters for switch_is_active, flag_is_active, sample_is_active #510

Open
@MatthewEthanTam

Description

@MatthewEthanTam

In my usage of Django-waffle, I found that I cannot use the switch template tag within an if statement's condition in Django templates as some blocks of code require both the switch to be active and another context variable to be set.

Please find an example of this case below:

{% switch 'switch'%}
  {% if context_variable %}
    modified message
  {% else %}
    default message
  {% endif %}
{% else %}
  default
{%endswitch%}

Suggestion: I suggest we make template filters for switch_is_active, flag_is_active, and sample_is_active, this will allow the reduction of redundant code in this scenario.

an example of this suggestion is below:

{% if 'switch'|switch_is_active and context_variable%}
  modified message
{% else %}
  default message
{% endif %}

If this is a good suggestion, I can make a PR for it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions