Constructor
new Formatter(object)
Default values for the markers are ${
and }
Default values for the markers are ${
and }
Name | Type | Description |
---|---|---|
object | object |
- Since
- 1.12.0
- Copyright
- schukai GmbH
- License
- AGPLv3
value is not a object
- Type
- TypeError
import {Formatter} from '@schukai/monster/source/text/formatter.mjs';
new Formatter({
a: {
b: {
c: "Hello"
},
d: "world",
}
}).format("${a.b.c} ${a.d | ucfirst}!"); // with pipe
// ↦ Hello World!
Members
defaults
PropertiesName | Type | Default | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
marker | object | Properties
| |||||||||||||
parameter | object | Properties
| |||||||||||||
callbacks | object | {} |
Methods
format(text) → {string}
Name | Type | Description |
---|---|---|
text | string |
value is not a string
- Type
- TypeError
too deep nesting
- Type
- Error
- Type:
- string
setMarker(open, close) → {Formatter}
Set new Marker
Default values for the markers are ${
and }
formatter.setMarker('#'); // open and close are both #
formatter.setMarker('[',']');
formatter.setMarker('i18n{','}');
.Set new Marker
Default values for the markers are ${
and }
formatter.setMarker('#'); // open and close are both #
formatter.setMarker('[',']');
formatter.setMarker('i18n{','}');
Name | Type | Description |
---|---|---|
open | array | | |
close | array | |
- Since
- 1.12.0
value is not a string
- Type
- TypeError
- Type:
- Formatter
setParameterChars(delimiter, assignment) → {Formatter}
Set new Parameter Character
Default values for the chars are ::
and =
formatter.setParameterChars('#');
formatter.setParameterChars('[',']');
formatter.setParameterChars('i18n{','}');
.Set new Parameter Character
Default values for the chars are ::
and =
formatter.setParameterChars('#');
formatter.setParameterChars('[',']');
formatter.setParameterChars('i18n{','}');
Name | Type | Description |
---|---|---|
delimiter | string | |
assignment | string |
- Since
- 1.24.0
value is not a string
- Type
- TypeError
- Type:
- Formatter