Sanitizes a string for use in URLs or HTML attributes. The resulting string contains only lowercase letters a-z, numbers 0-9, hyphens -, and optionally dots .. This method is also suitable for filenames, as it preserves dots as file extension separators by default.
@{ variable | sanitize (removeDots, maxChars) }
Parameters
- removeDots false
- Optionally also removes all dots from the string. The default is
false. - maxChars 100
- The maximum length of the returned string. The default is
100.
Example
The following example will include the template name as value for the class attribute for a template's body element to serve as an additional selector in CSS:
<body class="@{ :template | sanitize }">
Body content ...
</body>