How to include a macro in another file?
kamlekar opened this issue · comments
Venkateshwar commented
I have three file structures like:
_skeleton-content.html
<div class="page-content"></div>
{% block include_footer %}
{% endblock %}
_macros.html
{% macro script(files) %}
{% for file in files %}
<script type="text/javascript" src="{{ file }}"></script>
{% endfor %}
{% endmacro %}
index.html
{% extends "sections/_skeleton-content.html" %}
{% include "sections/_macros.html" %}
{% block include_footer %}
{{ script(['jquery.js','home.js']) }}
{% endblock %}
But this isn't working. The error is
unable to call script which is undefined or falsey
Venkateshwar commented
I got it.
I need to use import
statement. Sorry for this.
Kristijan Husak commented
@kamlekar, for these kind of things check the nunjucks docs, this is just the compiler plugin.