Search code examples
node.jsswig-template

Nodejs/Swig If then extends (Conditional Inheritance)


I am looking for a way in Swig that if a variable is set then extend a layout.

 {% set AjaxLoaded = "True" %}
 {% if AjaxLoaded %}
      im ajax
 {% else %}
      {% extends 'base.html' %}
      {% block Content %}
           im not ajax
      {% endblock %}
 {% endif %}

For some reason swig always extends base.html

i know if php/twig they have "Conditional Inheritance"

 {% extends var ? "minimum.html" : "base.html" %}

Thanks!


Solution

  • You cannot create conditional extends or blocks in Swig Templates.