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: Node

Template node used to skip blocks that contain disabled apps.

Helps with decoupling.

Parameters:
  • app_name (str)

  • nodelist (NodeList)

render(context) str

Render if the app is installed or return an empty string.

Return type:

str

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.events app is enabled in the settings, a link to the app is shown. If it is disabled, the entire block is ignored.