-
Notifications
You must be signed in to change notification settings - Fork 75
Description
Is your feature request related to a problem? Please describe.
Currently, when working with template variables in Element Mas, there is no way to apply regular expression replacements. This forces users to chain multiple replace filters together to achieve complex string transformations, resulting in very long and hard-to-maintain template chains.
For example, removing all special characters from a username requires an extremely long filter chain:
{{ user.preferred_username | replace("ä", "ae") | replace("ö", "oe") | replace("ü", "ue") | replace("Ä", "Ae") | replace("Ö", "Oe") | replace("Ü", "Ue") | replace("ß", "ss") | replace("_", "-") | replace(".", "") | replace("@", "") | replace(" ", "") | replace("$", "") | replace("%", "") | replace("&", "") | replace("#", "") | replace("!", "") | replace("+", "") | replace("=", "") | replace("*", "") | replace("(", "") | replace(")", "") | lower }}
Attempting to use a regex_replace filter currently results in: unknown filter: filter regex_replace is unknown
Describe the solution you'd like
Implement a regex_replace filter that accepts a regular expression pattern and a replacement string. This would allow complex string transformations in a single, readable filter call:
{{ user.preferred_username | regex_replace("[^A-Za-z0-9-]", "") | lower }}
Describe alternatives you've considered
- Using multiple chained
replacefilters (current workaround, but becomes unwieldy with many patterns) - Preprocessing usernames before passing them to templates (adds complexity to the application logic)
- Creating custom template functions outside the templating system (requires additional code maintenance)
A native regex_replace filter would be the most maintainable and user-friendly solution.