Skip to main content

Class: Substituter

actions/GenerateSnippet/Substituter.Substituter

This class constructs random strings that can be used as placeholders for the strings you'd like to insert into a document. This functionality is useful if the strings you'd like to insert might get modified by something like json serialization. You proceed by calling addSubstitution for each string you'd like to put into your document. This function returns a random id that you can put into your text. When you are done, call makeSubstitutions on the final text to replace the random id's with the original strings you desired.

Constructors

constructor

new Substituter()

Properties

substitutions

Private substitutions: Substitution[] = []

Defined in

actions/GenerateSnippet/Substituter.ts:18

Methods

addSubstitution

addSubstitution(to, isQuoted?): string

Get a random id that can be put into your text body that will then be replaced by {@link to} when you call makeSubstitutions.

Parameters

NameTypeDefault valueDescription
tostringundefinedThe string that you'd like to end up in the final document after replacements
isQuotedbooleanfalseUse this variable to indicate that in the final text the variable will end up quoted. This occurs if you use the replacement string as a stand alone string in a json document and then you serialize it

Returns

string

A unique random id that can be put into the document that will then be substituted later

Defined in

actions/GenerateSnippet/Substituter.ts:31


makeSubstitutions

makeSubstitutions(text): string

Performs substitutions on {@link text}, replacing the random ids generated by addSubstitution with the values passed in for to.

Parameters

NameTypeDescription
textstringThe text to perform substitutions on

Returns

string

The text with variable substituted for the original values you desired

Defined in

actions/GenerateSnippet/Substituter.ts:50