Answers.Body: <p>You can do this with the Luke Holder's <a href="https://github.com/lukeholder/craft-inflect" rel="nofollow">Inflect plugin</a>. Which method to use would depend on how you want the resulting text to look. I'd use <code>{{ myTextField|slugify }}</code> to get a string that looks like this "this-is-my-class", since I only use lowercase and hyphenate class/id names.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-13T13:03:49.643Z
Answers.Text: Looks like I was a little to quick when hitting the accepted answer button :) The Inflect plugin doesn't seem to convert characters in the string to class/id safe characters. Any advice on this?
Answers.UserDisplayName: Alf Vestre
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-13T13:46:17.707Z
Answers.Text: What characters isn't converted?
Answers.UserDisplayName: André Elvan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-14T06:36:30.343Z
Answers.Text: From my tests it seems like only spaces and casing are affected by the Inflect plugin. No other characters are converted, I have tested these so far: æøåüëäéóú
Answers.UserDisplayName: Alf Vestre
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-08T13:30:17.203Z
Answers.LastActivityDate: 2014-10-08T13:30:17.203Z
Answers.UserDisplayName: André Elvan
Body: <p>Does anyone know if it is possible to apply a Twig filter or use escaping to convert a Craft textfield into a html class/id safe string?</p>
  
Tags: <templating><filter><escaping>
Title: Convert textfield to be used in html class or id?
ThreadText: # Convert textfield to be used in html class or id?
  
  (Asked by: username_0 on 2014-10-08)
  
  Does anyone know if it is possible to apply a Twig filter or use escaping to convert a Craft textfield into a html class/id safe string?
  
  **Tags:** templating, filter, escaping
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-10-08. Score: 1 | Accepted answer
  
  You can do this with the Luke Holder's [Inflect plugin](https://github.com/lukeholder/craft-inflect). Which method to use would depend on how you want the resulting text to look. I'd use `{{ myTextField|slugify }}` to get a string that looks like this "this-is-my-class", since I only use lowercase and hyphenate class/id names.
  
  > **Comments:**
  > **username_0**: Looks like I was a little to quick when hitting the accepted answer button :) The Inflect plugin doesn't seem to convert characters in the string to class/id safe characters. Any advice on this?  
  > **username_1**: What characters isn't converted?  
  > **username_0**: From my tests it seems like only spaces and casing are affected by the Inflect plugin. No other characters are converted, I have tested these so far: æøåüëäéóú  
  
  ---
  
  