carlitoplatanito / gulp-nunjucks-render

[Gulp](https://github.com/wearefractal/gulp) plugin to render [Nunjucks](http://mozilla.github.io/nunjucks/) templates
149 stars 33 forks source link

How to include a macro in another file? #42

Closed kamlekar closed 8 years ago

kamlekar commented 8 years ago

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

kamlekar commented 8 years ago

I got it.

I need to use import statement. Sorry for this.

kristijanhusak commented 8 years ago

@kamlekar, for these kind of things check the nunjucks docs, this is just the compiler plugin.