0

I am developing a template for a client in Hubspot's COS and I am struggling to find a HubL filter that will convert a text/string into a slug format.

For example, I want to be able to convert This Text into this-text. My goal is to use this feature to dynamically assign a css class based on a module text field.

I am looking for an equivalent feature to WordPress' sanitize_title() function.

HubL is based on Python. I am not sure what native Python features work in HubL, but I would be open to that approach as well.

If anyone has accomplished this and has some insight it would be much appreciated.

Thanks!

Marc
  • 4,661
  • 3
  • 40
  • 62

1 Answers1

1
{% set var = "This Text" %}
{{ var|lower|replace(' ','-') }}

There's a space between the quotation marks in replace's first argument.

fenceop
  • 1,439
  • 3
  • 18
  • 29
DerickB
  • 109
  • 9