I have a base-theme.html template with several {% include 'theme-component.html' %} tags.
I also have a context processor that provides a dict of some general items needed by the template - config, menuItems, etc.
The context_processor sends information to the base them when I include them in the base-theme.html directly, but not when I put them in the included template.
For example:
base-theme.html
<!doctype html...
{{ config.site_name }}
{% include 'menu.html' %}
</html>
The above works.
menu.html
<nav>
{% for item in menuItems %}
{{ item }}
{% endfor %}
</nav>
This does not work
Can anyone point me in the right direction as to why this is happening?
To do like that send Menu Item context from your view. Include just includes the template but using it as context you need to send the context
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.