Constructor
new StringTemplateBuilder(setup)
Creates an instance of StringTemplateBuilder.
Parameters:
| Name | Type | Description | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
setup |
Object | The configuration for the string template builder instance. Properties
|
- Source:
Methods
end() → {string}
Finalizes the template and returns the generated string.
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. |
Returns:
The current StringTemplateBuilder instance for method chaining.
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. |
Returns:
The current StringTemplateBuilder instance for method chaining.
separator() → {StringTemplateBuilder}
Appends a separator line to the template.
Returns:
The current StringTemplateBuilder instance for method chaining.
tab() → {StringTemplateBuilder}
Appends a tab indentation to the template.
Returns:
The current StringTemplateBuilder instance for method chaining.
text(value) → {StringTemplateBuilder}
Appends a string value to the template.
Parameters:
| Name | Type | Description |
|---|---|---|
value |
string | The string value to append to the template. |
Returns:
The current StringTemplateBuilder instance for method chaining.
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. |
Returns:
The current StringTemplateBuilder instance for method chaining.
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. |
Throws:
-
When either
nameortypeis missing. - Type
- Error.Log
Returns:
The current StringTemplateBuilder instance for method chaining.