Nunjucks Append
Allows one to define a tag that subviews can append content to. Handy for letting subviews add resources to the head or footer, for example.
Example:
The layout - /views/layouts/default.html
:
The Title {% output "javascript" %} {% endoutput %} {% block content %}{% endblock %}
The view - /views/index.html
:
{% extends "/layouts/default.html" %} {% append "javascript" %}<!-- Will be output beneath jquery.js --><script src="/index-script.js"></script>{% endappend %} {% block content %}<div> <p>The content</p></div>{% endblock %}
The output:
The Title <!-- Will be output beneath jquery.js --> The content