• ♡ Sponsor

    sanitize

    #URL

    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>
    

    Related

    Toolbox  ⁄
    queryStringMerge — Toolbox

    Creates a query string containing the specified paramters as key/value pairs merged with the existing query string of the current URL. This method can be used to create links for adding or replacing some parameters of the query string without touching the other ones. A standard ...

    Toolbox  ⁄
    redirect — Toolbox

    Redirects the current page to a given URL.

    • Automad
    • Developer Guide
    • Building Themes
    • Template Language
    • Pipe
    • sanitize
    Discuss
    Packages
    Release Notes
    Support
    Terms of Use
      Become a Sponsor
      GitHub
      Twitter
      Facebook
      Instagram
      2013-2023 by Marc Anton Dahmen
    Released under the MIT license

    A faceless machine, creating one's portrait in the internet.
  • Automad
  • Getting Started
  • System
  • User Guide
  • Developer Guide
  • Headless Mode
  • Discuss
  • Packages
  • Developer Guide ←
  • Building Themes ←
  • Template Language ←
  • Pipe
  • ceil
  • dateFormat
  • def
  • escape
  • findFirstImage
  • findFirstParagraph
  • floor
  • markdown
  • match
  • replace
  • round
  • sanitize
  • shorten
  • stripEnd
  • stripStart
  • stripTags
  • strlen
  • strtolower
  • strtoupper
  • ucwords