Class: StringTemplateBuilder

StringTemplateBuilder(setup)

Class representing a string template builder with various formatting capabilities.

Constructor

new StringTemplateBuilder(setup)

Creates an instance of StringTemplateBuilder.

Parameters:
Name Type Description
setup Object

The configuration for the string template builder instance.

Properties
Name Type Attributes Default Description
indentation number <optional>
4

The number of spaces to use for each indentation level.

Source:

Methods

end() → {string}

Finalizes the template and returns the generated string.

Source:
Returns:

The generated string template.

Type
string

indent(indentationopt) → {StringTemplateBuilder}

Appends a specific number of spaces for indentation to the template.

Parameters:
Name Type Attributes Default Description
indentation number <optional>
this.indentation

The number of spaces to use for indentation.

Source:
Returns:

The current StringTemplateBuilder instance for method chaining.

Type
StringTemplateBuilder

newLine(charopt) → {StringTemplateBuilder}

Appends a new line character to the template.

Parameters:
Name Type Attributes Default Description
char string <optional>
'\n'

The character to represent a new line.

Source:
Returns:

The current StringTemplateBuilder instance for method chaining.

Type
StringTemplateBuilder

separator() → {StringTemplateBuilder}

Appends a separator line to the template.

Source:
Returns:

The current StringTemplateBuilder instance for method chaining.

Type
StringTemplateBuilder

tab() → {StringTemplateBuilder}

Appends a tab indentation to the template.

Source:
Returns:

The current StringTemplateBuilder instance for method chaining.

Type
StringTemplateBuilder

text(value) → {StringTemplateBuilder}

Appends a string value to the template.

Parameters:
Name Type Description
value string

The string value to append to the template.

Source:
Returns:

The current StringTemplateBuilder instance for method chaining.

Type
StringTemplateBuilder

textColumn(text, lengthopt) → {StringTemplateBuilder}

Appends a text with a specific column length to the template.

Parameters:
Name Type Attributes Default Description
text string

The text to append.

length number <optional>
this.textColumnLength

The column length.

Source:
Returns:

The current StringTemplateBuilder instance for method chaining.

Type
StringTemplateBuilder

var(name, type) → {StringTemplateBuilder}

Appends a variable placeholder to the template.

Parameters:
Name Type Description
name string

The name of the variable.

type string

The type of the variable.

Source:
Throws:

When either name or type is missing.

Type
Error.Log
Returns:

The current StringTemplateBuilder instance for method chaining.

Type
StringTemplateBuilder