Konstantin Demin
a69d6c2920
also: - drop "njs" directories (not actually used nor useful) - rework jinja filters: more functions, shorter names, etc.
172 lines
3.6 KiB
Django/Jinja
172 lines
3.6 KiB
Django/Jinja
j2cfg:
|
|
{{ j2cfg }}
|
|
|
|
{% set x = [1,2,3,4] %}
|
|
x = {{ x }}
|
|
is_sequence:
|
|
{{ x | is_sequence }}
|
|
|
|
{% set x = {1:2,3:4} %}
|
|
x = {{ x }}
|
|
is_sequence:
|
|
{{ x | is_sequence }}
|
|
|
|
{% set x = [1,2,3,4] %}
|
|
x = {{ x }}
|
|
is_mapping:
|
|
{{ x | is_mapping }}
|
|
|
|
{% set x = {1:2,3:4} %}
|
|
x = {{ x }}
|
|
is_mapping:
|
|
{{ x | is_mapping }}
|
|
|
|
{% set x = [2,3,1,2] %}
|
|
x = {{ x }}
|
|
uniq:
|
|
{{ x | uniq }}
|
|
|
|
{% set x = ['2',3,'1','2'] %}
|
|
x = {{ x }}
|
|
remove_non_str:
|
|
{{ x | remove_non_str }}
|
|
|
|
{% set x = ['2','','1','2'] %}
|
|
x = {{ x }}
|
|
remove_empty_str:
|
|
{{ x | remove_empty_str }}
|
|
|
|
{% set x = ['2','3','1','2'] %}
|
|
x = {{ x }}
|
|
uniq_str_list:
|
|
{{ x | uniq_str_list }}
|
|
|
|
{% set x = '2 3 1 2 ' %}
|
|
"x = {{ x }}"
|
|
str_split_to_list:
|
|
{{ x | str_split_to_list }}
|
|
|
|
{% set x = '2:3::1:2:' %}
|
|
"x = {{ x }}"
|
|
str_split_to_list(':'):
|
|
{{ x | str_split_to_list(':') }}
|
|
|
|
{% set x = { 'VAR1': 'Etc/UTC', 'VAR2': '', 'VAR3': None, '4VAR4': 'yeah', 'VAR5=not': 'yeah', 'VAR5=real yeah': None, 'VAR6': {'pi': 3.1415926}, 'VAR7': ['pi', 3.1415926] } %}
|
|
x = {{ x }}
|
|
dict_to_env_str_list:
|
|
{{ x | dict_to_env_str_list }}
|
|
|
|
{% set x = '1 2 3 4' %}
|
|
"x = {{ x }}"
|
|
any_to_str_list:
|
|
{{ x | any_to_str_list }}
|
|
|
|
{% set x = [1,2,3,4] %}
|
|
x = {{ x }}
|
|
any_to_str_list:
|
|
{{ x | any_to_str_list }}
|
|
|
|
{% set x = 3.1415926 %}
|
|
x = {{ x }}
|
|
any_to_str_list:
|
|
{{ x | any_to_str_list }}
|
|
|
|
{% set x = ['a2','b3','c1','d2'] %}
|
|
x = {{ x }}
|
|
is_re_match('[ab]'):
|
|
{{ x | is_re_match('[ab]') }}
|
|
is_re_match('[mn]'):
|
|
{{ x | is_re_match('[mn]') }}
|
|
|
|
{% set x = ['a2','b3','c1','d2'] %}
|
|
x = {{ x }}
|
|
is_re_fullmatch('[ab]'):
|
|
{{ x | is_re_fullmatch('[ab]') }}
|
|
is_re_fullmatch('[ab][12]'):
|
|
{{ x | is_re_fullmatch('[ab][12]') }}
|
|
|
|
{% set x = ['a2','b3','c1','d2'] %}
|
|
x = {{ x }}
|
|
re_match('[ab]'):
|
|
{{ x | re_match('[ab]') }}
|
|
re_match('[mn]'):
|
|
{{ x | re_match('[mn]') }}
|
|
|
|
{% set x = ['a2','b3','c1','d2'] %}
|
|
x = {{ x }}
|
|
re_fullmatch('[ab]'):
|
|
{{ x | re_fullmatch('[ab]') }}
|
|
re_fullmatch('[ab][12]'):
|
|
{{ x | re_fullmatch('[ab][12]') }}
|
|
|
|
{% set x = ['a2','b3','c1','d2'] %}
|
|
x = {{ x }}
|
|
re_match_negate('[ab]'):
|
|
{{ x | re_match_negate('[ab]') }}
|
|
re_match_negate('[mn]'):
|
|
{{ x | re_match_negate('[mn]') }}
|
|
|
|
{% set x = ['a2','b3','c1','d2'] %}
|
|
x = {{ x }}
|
|
re_fullmatch_negate('[ab]'):
|
|
{{ x | re_fullmatch_negate('[ab]') }}
|
|
re_fullmatch_negate('[ab][12]'):
|
|
{{ x | re_fullmatch_negate('[ab][12]') }}
|
|
|
|
{% set x = ['a2b','b3b','c1f','d2g'] %}
|
|
x = {{ x }}
|
|
re_sub('[ab]', '_'):
|
|
{{ x | re_sub('[ab]', '_') }}
|
|
re_sub('[mn]', '_'):
|
|
{{ x | re_sub('[mn]', '_') }}
|
|
|
|
{% set x = 'j2cfg-multi.py' %}
|
|
x = {{ x }}
|
|
sh_like_file_to_list:
|
|
{{ 'j2cfg-multi.py' | sh_like_file_to_list }}
|
|
|
|
{% set x = 'Accept-Encoding' %}
|
|
x = {{ x }}
|
|
as_cgi_header:
|
|
{{ x | as_cgi_header }}
|
|
|
|
{% set x = '_Permissions-Policy--' %}
|
|
x = {{ x }}
|
|
as_cgi_header:
|
|
{{ x | as_cgi_header }}
|
|
|
|
{% set x = 'VAR1=Etc/UTC' %}
|
|
x = {{ x }}
|
|
any_to_env_dict:
|
|
{{ x | any_to_env_dict }}
|
|
|
|
{% set x = ['VAR1=Etc/UTC', 'VAR2=', 'VAR3', '4VAR4=yeah', 'VAR5=yeah', 'VAR5=not-yeah'] %}
|
|
x = {{ x }}
|
|
any_to_env_dict:
|
|
{{ x | any_to_env_dict }}
|
|
|
|
{% set x = { 'VAR1': 'Etc/UTC', 'VAR2': '', 'VAR3': None, '4VAR4': 'yeah', 'VAR5=not': 'yeah', 'VAR5=real yeah': None, 'VAR6': {'pi': 3.1415926}, 'VAR7': ['pi', 3.1415926] } %}
|
|
x = {{ x }}
|
|
any_to_env_dict:
|
|
{{ x | any_to_env_dict }}
|
|
|
|
{% set x = { 'VAR1': 'Etc/UTC', 'VAR2': '', 'VAR3': None, '4VAR4': 'yeah', 'VAR5=not': 'yeah', 'VAR5=real yeah': None, 'VAR6': {'pi': 3.1415926}, 'VAR7': ['pi', 3.1415926] } %}
|
|
x = {{ x }}
|
|
dict_keys:
|
|
{{ x | dict_keys }}
|
|
dict_empty_keys:
|
|
{{ x | dict_empty_keys }}
|
|
dict_non_empty_keys:
|
|
{{ x | dict_non_empty_keys }}
|
|
|
|
{% set x = [1,2,3,4] %}
|
|
{% set y = [3,4,5,6] %}
|
|
list_diff(x, y):
|
|
{{ x | list_diff(y) }}
|
|
list_diff(y, x):
|
|
{{ y | list_diff(x) }}
|
|
list_intersect(x, y):
|
|
{{ x | list_intersect(y) }}
|
|
list_intersect(y, x):
|
|
{{ y | list_intersect(x) }}
|