/ LJCPHPCodeDoc / LJCTextBuilderLib / LJCTextBuilder / Line


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
Line(text = null, addIndent = true, allowNewLine = true)

Appends a potentially indented text line to the builder.

Remarks

Line() is an "Append" method. It creates the text with GetText() and adds a new line after the text. The text is then added to the builder.
Line() works the same as Text() except it appends a new line.

Example

JavaScript
// Appends a potentially indented text line to the builder.
Line()
{
  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.
  // Ends the text with a newline.
  tb.Line("First Line");
  tb.Line("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.