How to add a custom filter for use in a cookiecutter template?
Asked Answered
I

0

7

how can I add a custom filter to be used in a jinja template used by cookiecutter?

I tried adding using a pre_gen_project hook, it's called, but I can't find a way to make my python functions visible as jinja filters (or function) inside the templates.

Incertitude answered 29/4, 2015 at 19:59 Comment(4)
Have you read the jinja2 docs?Cervin
Yes, using the filter decorators didn't work nor adding to a new enviroment's filter dict. I must be missing something.Creolized
you should show your filter code and how you call your filter in jinja2 envAzelea
This is possible using local extensions. See cookiecutter.readthedocs.io/en/latest/advanced/…Shrunk

© 2022 - 2024 — McMap. All rights reserved.