jinja2-cli icon indicating copy to clipboard operation
jinja2-cli copied to clipboard

Add the ability to import filters

Open mattrobenolt opened this issue 5 years ago • 7 comments

Fixes #85

mattrobenolt avatar Apr 24 '20 04:04 mattrobenolt

I like this one a lot. Why is is not merged?

braindevices avatar Jul 10 '20 19:07 braindevices

I think it was just waiting on some outside confirmation. Wanna try it out? :)

mattrobenolt avatar Jul 11 '20 00:07 mattrobenolt

I think it was just waiting on some outside confirmation. Wanna try it out? :)

I've been testing out this update, and it works as expected. I successfully tested both single and multiple filters (e.g. jinja2 -f myfilter.myfunction -f ansible.plugins.filter.core.combine test.txt).

jjsp556 avatar Sep 08 '20 22:09 jjsp556

I hope you will merge this, since I really need this feature :) I looked through the code, and its very simple and elegant, and its hard for me to see how anything could go wrong. Sincerely.

velle avatar Sep 08 '22 08:09 velle

Is there any chance to see this PR merged into main branch? It can drastically extend jina2-cli capabilities.

I tested this patch and it works fine. For example, we have hostname and want to add ip address in rendered config file, so it can be one simple filter (filters/ip.py):

import socket

def get_ip(hostname):
    return socket.gethostbyname(hostname)

and in template it can be

{{ hostname }}: {{ hostname | get_ip }}
jinja2 -f filters.ip.get_ip test.j2 test.yaml

tierpod avatar Nov 23 '22 07:11 tierpod

@mattrobenolt any chances to merge this change?

sfc-gh-turbaszek avatar Mar 20 '23 14:03 sfc-gh-turbaszek