314ma

jinja replacement

Sep 29th, 2020 (edited)
81
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 }}
RAW Paste Data