@metreeca/core - v0.9.22
    Preparing search index...

    Function fill

    • Fills the placeholders of a template string.

      Replaces every {key} placeholder with the value variables maps the key to, leaving the rest of the template as it stands, so that a string written with the shape of its result is completed from values computed elsewhere.

      A modifier before the opening brace states how a placeholder is filled:

      • {key} is replaced with the value
      • %{key} is replaced with the URL-encoded value
      • #{key} is preserved as {key}, not replaced

      URL-encoding percent-encodes every character but the unreserved ones, that is the ASCII letters, the decimal digits and -._~, so an encoded value is safe at any position of a URL, the query and the fragment included.

      Keys are made of word characters, that is the ASCII letters, the decimal digits and the underscore; braces enclosing anything else are content and are left as they stand.

      Parameters

      • string: string

        The template to fill

      • variables: Resolver

        The Resolver supplying the value each placeholder key stands for

      Returns string

      A copy of string with every placeholder replaced by the value variables maps its key to, percent-encoded where the placeholder is marked with %, and every #-marked placeholder left unfilled and stripped of its modifier

      If variables maps no value to the key of a placeholder to be filled

      If a value to be percent-encoded carries an isolated surrogate, which denotes no character and has no UTF-8 representation