• Creates a new placeholder.

    Parameters

    • name: string

      The name of the placeholder.

    • Optional options: {
          apply_fn?: ((str, context?) => Promise<{
              result: string;
              [key: string]: unknown;
          }>);
          categories?: PlaceholderCategory[];
          constant?: boolean;
          description?: string;
          example?: string;
          fullRepresentation?: string;
          hintRepresentation?: string;
          regex?: RegExp;
          replace_with?: string;
          rules?: ((str, context?) => Promise<boolean>)[];
          type?: PlaceholderType;
      }
      • Optional apply_fn?: ((str, context?) => Promise<{
            result: string;
            [key: string]: unknown;
        }>)
          • (str, context?): Promise<{
                result: string;
                [key: string]: unknown;
            }>
          • The function to apply to the placeholder. Specify either this or replace_with.

            Parameters

            • str: string

              The string to apply the placeholder to.

            • Optional context: {
                  [key: string]: unknown;
              }

              The context object to store & retrieve values from.

              • [key: string]: unknown

            Returns Promise<{
                result: string;
                [key: string]: unknown;
            }>

            An object containing the result of the placeholder and any other values to store in the context object.

      • Optional categories?: PlaceholderCategory[]

        The categories of the placeholder.

      • Optional constant?: boolean

        Whether the placeholder's value is constant over the course of a single run.

      • Optional description?: string

        A brief description of the placeholder.

      • Optional example?: string

        An example of the placeholder in use.

      • Optional fullRepresentation?: string

        A representation of the placeholder to show in detailed explanations.

      • Optional hintRepresentation?: string

        A representation of the placeholder to show in hints.

      • Optional regex?: RegExp

        The regex to match the placeholder.

      • Optional replace_with?: string

        The string to replace the placeholder with. Specify either this or apply_fn. Can include other placeholders.

      • Optional rules?: ((str, context?) => Promise<boolean>)[]

        The rules that determine whether or not the placeholder is relevant in the current context.

        Param

        The string to check the rules against.

        Param

        The context object to store & retrieve values from.

        Returns

        True if the placeholder should be replaced, false otherwise.

      • Optional type?: PlaceholderType

        The type of the placeholder.

    Returns Placeholder

    A placeholder object.

Generated using TypeDoc