• ♡ Sponsor

    match

    #Regex

    Performs a Regex match and returns 1 if the given pattern matches and 0 if not.

    @{ variable | match (regex) }
    

    Parameters

    regex
    A valid regex pattern, wrapped in delimiters like "/pattern/".

    Note that you will have to use double backslashes \\ to escape reserved characters in regex patterns.

    Example

    The following example checks whether a template name contains the word post and therefore uses a different date format:

    <@ if @{ :template | match ('/post/') } @>
        @{ date | dateFormat (@{ formatPost }) }
    <@ else @>
        @{ date | dateFormat (@{ formatProject }) }
    <@ end @>
    

    Related

    Pipe  ⁄
    replace — Pipe

    Performs a regular expression search and replace.

    Toolbox  ⁄
    newPagelist — Toolbox

    Creates a new pagelist object. The current pagelist will be replaced. A foreach loop can be used to iterate over the pagelist object. This method does not have any output. To only update the configuration of the current pagelist, without resetting all other parameters, the ...

    Toolbox  ⁄
    pagelist — Toolbox

    Modifies the currently defined pagelist pagelist object. Only specified options will be changed, all others will be preserved. To restore a default pagelist and reset all options, the newPagelist method can be used.

    Objects  ⁄
    Pagelist — Objects

    The pagelist contains by default all pages which are not hidden and therefore has no defined type. Changing the pagelist type to one of the following available types will update the selection of pages accordingly. The main purpose of this object is to provide an easy way of ...

    • Automad
    • Developer Guide
    • Building Themes
    • Template Language
    • Pipe
    • match
    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