how to implement a "decorator" pattern that processes an entire template

10 views
Skip to first unread message

Jacob G

unread,
Nov 25, 2015, 11:20:34 AM11/25/15
to Nunjucks
I'd like to have a way for a template to process an entire chunk of data, particularly to:
  1. create a zip file of entire template
  2. create an excel file, which takes the inner contents and creates a zip file along with other meta data
Is the macro tag the only way to do this? i.e. along the lines of:

{% macro my_contents(data) %}

{% endmacro %}

{{ my_contents(data) | zip }}

For clarity, I think I'd prefer a syntax like this:

{% pipeline zip %}
... MY TEMPLATE CONTENTS ...
{% endpipeline %}

Thoughts?

Carl Meyer

unread,
Dec 16, 2015, 12:58:50 AM12/16/15
to Nunjucks
Hi Jacob,

I'm not entirely sure I understand what you mean, but I think perhaps the `filter` tag would be useful to you: http://mozilla.github.io/nunjucks/templating.html#filter

Carl
Reply all
Reply to author
Forward
0 new messages