loefsys.core.templatetags.requireapp module
Template tags module for not rendering blocks when certain apps aren’t installed.
- class loefsys.core.templatetags.requireapp.RequireAppNode(app_name: str, nodelist: NodeList)
Bases:
NodeTemplate node used to skip blocks that contain disabled apps.
Helps with decoupling.
- Parameters:
app_name (str)
nodelist (NodeList)
- loefsys.core.templatetags.requireapp.do_requireapp(parser, token)
Template tag that skips blocks if a certain app is disabled.
Checks whether an app is enabled, and if it is, outputs the contents of the block:
- {% requireapp ‘loefsys.events’ %}
<a href=”{% url ‘events:events’ %}”>Activiteiten</a>
{% endrequireapp %}
In the example above, if the
loefsys.eventsapp is enabled in the settings, a link to the app is shown. If it is disabled, the entire block is ignored.