Function formatPlaceholder

  • Returns the replaced string of the source string (named placeholder) with the given parameters

    Parameters

    • Optionaltext: null | string

      the source string to inspect

    • Optionalparams: {
          [key: string]: any;
      }

      the parameters to replaced with, in the form of key values

      • [key: string]: any

    Returns string | undefined | null

    the replaced string of the source string

    formatPlaceholder("foo{bar}", {bar: "bar"});    //  "foobar"
    formatPlaceholder("foobar{none}"); // "foobar{none}"
    formatPlaceholder("foobar{none}", {}); // "foobar{none}"
    formatPlaceholder("hello {name}, foo{bar}", {name: "world", bar: "bar"}); // "hello world, foobar"