/ LJCPHPCodeDoc / LJCTextBuilderLib / LJCTextBuilder / Text


Parameters
text - The add text.
addIndent - Indicates if the element can be indented.
allowNewLine - Indicates if a new line can be added.

Returns

The potentially indented and wrapped new text value.

Syntax

JavaScript
Text(text, addIndent = true, allowNewLine = true)

Appends the potentially indented text.

Remarks

Text() is an "Append" method. It creates the text with GetText() and adds it to the builder.
Note: One should set the "addIndent" parameter to false when adding text to the builder after getting the text with a "GetText" method. This is because the the indent has already been added with the "GetText" method.

Example

JavaScript
// Appends the potentially indented text.
Text()
{
  const tb = new LJCTextBuilder();
  tb.AddIndent();

  // Example Method:
  // Starts the text with a newline if the builder already has text, param
  // allowNewLine = true and builder text does not end with a newline.
  // The text begins with the current indent string if param
  // addIndent = true.
  tb.Text("First Line");
  tb.Text("This is some indented text.");

  const result = tb.ToString();

  // result:
  // "First Line"
  // "  This is some indented text."
}

Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.