Skip to content

Nunjucks env #2694

Answered by boutell
myovchev asked this question in Q&A
Jan 21, 2021 · 5 comments · 5 replies
Discussion options

You must be logged in to vote

I think Miro is trying to change the nunjucks environment before it is used, which is a slightly different issue.

However I don't see how the new situation is different in this regard, because you would have had to do it the same way before, I think... you should be able to do whatever you like to each nunjucks "env" before it's ever used if you use -

// in project level @apostrophecms/template
extendMethods(self, options) {
  return {
    newEnv(_super, req, name, folders) {
      const env = _super(req, name, folders);
      // do something here
      return env;
    }
  };
}

Also note there is a filters option to the templates module that can be used to pass nunjucks filters in with l…

Replies: 5 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@myovchev
Comment options

myovchev Jan 26, 2021
Maintainer Author

@myovchev
Comment options

myovchev Feb 7, 2021
Maintainer Author

Answer selected by myovchev
Comment options

You must be logged in to vote
1 reply
@myovchev
Comment options

myovchev Jan 29, 2021
Maintainer Author

Comment options

You must be logged in to vote
1 reply
@myovchev
Comment options

myovchev Feb 8, 2021
Maintainer Author

Comment options

You must be logged in to vote
1 reply
@myovchev
Comment options

myovchev Feb 8, 2021
Maintainer Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants