Advertisement
314ma

jinja replacement

Sep 29th, 2020 (edited)
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 0.37 KB | None | 0 0
  1. {% set replacements = { " ":"_", "ą":"a", "ę":"e", "ć":"c", "ł":"l", "ó":"o", "ź":"z", "ś":"s" } %}
  2. {% set przyklad = "ąĘ ćł óŹś" %}
  3. {{ przyklad }}
  4. {% set data = namespace(value=przyklad|lower) -%}
  5. {% for r in replacements -%}
  6.   {% set data.value = data.value|replace(r, replacements[r]) -%}
  7. {% endfor -%}
  8. {% set przyklad = data.value -%}
  9. {{ przyklad }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement