• Constructs a regex for a placeholder container in the format {{name parameter1 parameter2 ... parameterN}}:value}}

    Parameters

    • name: string

      The name of the placeholder

    • parameters: (string | RegExp)[]

      The parameters of the placeholder

    • valueType: string | RegExp

      The type of the placeholder's value

    • Optional options: {
          braceType?: braceType;
          global?: boolean;
      }

      Options for the placeholder

      • Optional braceType?: braceType

        The type of braces to use

      • Optional global?: boolean

        Whether to match globally

    Returns RegExp

    A RegExp matching a placeholder container

    Example

    Using a container to match a placeholder and extract its value

    const placeholderRegex = Container("myPlaceholder", [], InnerText());
    const myPlaceholder = PLCreator.newPlaceholder("myPlaceholder", {
    regex: placeholderRegex,
    apply_fn: async (str, context) => {
    const matches = str.match(new RegExp(placeholderRegex.source));
    return { result: matches?.[3] || "" }
    }
    })
    const result = await PLApplicator.bulkApply("{{myPlaceholder:hello, world!}}", { customPlaceholders: [myPlaceholder] })
    console.log(result) // hello, world!

Generated using TypeDoc