Search code examples
gulpnunjucks

Template Render Error : Expect Block End in Enblock


Nunjucks throws this error when I am restarting GULP. I cannot see what the problem might be. Unfortunately Nunjucks does not give me the file or tag where this is happening.

events.js:141
      throw er; // Unhandled 'error' event
      ^
 Template render error: (unknown path)
  Template render error: expected block end in endblock statement
    at Object.exports.withPrettyErrors (D:\dev\ngs-frontend-next\node_modules\gulp-nunjucks-render\node_modules\nunjucks\src\lib.js:35:17)
    at Obj.extend.render (D:\dev\ngs-frontend-next\node_modules\gulp-nunjucks-render\node_modules\nunjucks\src\environment.js:374:20)
    at Obj.extend.renderString (D:\dev\ngs-frontend-next\node_modules\gulp-nunjucks-render\node_modules\nunjucks\src\environment.js:261:21)
    at Object.module.exports.renderString (D:\dev\ngs-frontend-next\node_modules\gulp-nunjucks-render\node_modules\nunjucks\index.js:66:14)
    at Transform._transform (D:\dev\ngs-frontend-next\node_modules\gulp-nunjucks-render\index.js:46:21)

It seems like I have the block and enblock correctly defined in my base index.html file. I have these two tags :

{% block content %}

.....

{% endblock include "components/cmpBreadcrumb/cmpBreadcrumb.html" %}

Any ideas?


Solution

  • Is there a reason you are including within the endblock? I can repeat the same error you had by coupling the include and endblock together in the same tag.

    From what I've read unless you are using a filter or something else naturally done together in a block they should be broken out into their own tags.

    If you want the include that file in the content it should be before the close,

    {% block content %}
      [...]
      {% include "components/cmpBreadcrumb/cmpBreadcrumb.html" %}
    {% endblock %}