Rules for determining whether or not a placeholder is relevant in a given context.
Rules are functions that take in a string and a context object and return a boolean. If the boolean is true, the placeholder is relevant and should be applied, otherwise it is not relevant. Rule checking is ignored by default for all PLApplicator functions. To enable rule checking, pass true for the checkRules argument.
Example
constnewPlaceholder = PLCreator.newPlaceholder("myPlaceholder", { rules: [PLRule.RequireActiveBrowser()], apply_fn:async (str, context) => { return { result:"myValue", myPlaceholder:"myValue" }; }, }) conststringToReplace = "Hello, I am {{myPlaceholder}}."; constresult = awaitPLApplicator.applyToString(stringToReplace, { customPlaceholders: [newPlaceholder], checkRules:true }) console.log(result) // "Hello, I am myValue." only if a browser is the frontmost application, otherwise "Hello, I am {{myPlaceholder}}."
Rules for determining whether or not a placeholder is relevant in a given context.
Rules are functions that take in a string and a context object and return a boolean. If the boolean is true, the placeholder is relevant and should be applied, otherwise it is not relevant. Rule checking is ignored by default for all PLApplicator functions. To enable rule checking, pass true for the
checkRules
argument.Example