sanitize
Cleans up a string to be used as URL or value for a HTML attribute. The returned string constists of the following characters: a-z
, 0-9
, -
and optional dots .
. This method is safe to be used with filenames as well, since it keeps dots as suffix 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>