Constructor
# new Formatter(object)
Default values for the markers are ${
and }
Parameters:
Name | Type | Description |
---|---|---|
object |
object |
- Since:
- 1.12.0
- Copyright:
- schukai GmbH
Throws:
-
value is not a object
- Type
- TypeError
Example
new Formatter({
a: {
b: {
c: "Hello"
},
d: "world",
}
}).format("${a.b.c} ${a.d | ucfirst}!");
// ↦ Hello World!
Methods
# format(text) → {string}
Parameters:
Name | Type | Description |
---|---|---|
text |
string |
Throws:
-
value is not a string
- Type
- TypeError
Returns:
- 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{','}');
Parameters:
Name | Type | Description |
---|---|---|
open |
string | |
close |
string |
- Since:
- 1.12.0
Throws:
-
value is not a string
- Type
- TypeError
Returns:
- Type
- Formatter