Skip to content

Instantly share code, notes, and snippets.

@morgyface
Created February 3, 2021 15:07
Show Gist options
  • Save morgyface/df963aef55867844b01004114374717a to your computer and use it in GitHub Desktop.
Save morgyface/df963aef55867844b01004114374717a to your computer and use it in GitHub Desktop.
Nunjucks | sanitize | replace whitespace with hyphens
{% set image = profile.name | lower | replace(" ", "-") %}
@morgyface
Copy link
Author

Nunjucks and sanitize_title_with_dashes

I failed in my search for a built in nunjucks filter which mimics the WordPress function sanitize_title_with_dashes.

However, I did discover if you combine lower with replace(" ", "-") you can get pretty close without too much fuss.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment