You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In one `message` there can only be one `selector`, but there can be unlimited number of `pipes` with unlimited number of `arguments` in them. It is possible to build dynamic `selector` (meaning `message` can be inside it), but it is not possible to build dynamic `pipes` except for `argument values`.
62
+
63
+
So both of these are valid:
64
+
1.`"Hello {agents.{index}.fistName}"`;
65
+
2.`"{a} + {b} = {a | sum, sequence:{b}}"`.
66
+
_(Note: sum is a custom transformer in this case)_.
67
+
68
+
### `message`
69
+
Contains everything between `{` and `}` that in large includes 1 `selector` and n `pipes`.
70
+
71
+
### `selector`
72
+
String value that points to value from given props object e.g.:
We can stack any number of arguments separated by `,` (comma).
44
117
45
118
### Global transformers
46
119
47
-
#### `number`
120
+
### `defaultTransformers`
121
+
122
+
-#### select
48
123
@TODO: Write about this
49
124
50
-
#### `plural`
125
+
-#### json
51
126
@TODO: Write about this
52
127
53
-
#### `date`
128
+
### `intlTransformers`
129
+
130
+
-#### number
54
131
@TODO: Write about this
55
132
56
-
#### `time`
133
+
-#### plural
57
134
@TODO: Write about this
58
135
59
-
#### `relativeTime`
136
+
-#### date
60
137
@TODO: Write about this
61
138
62
-
#### `select`
139
+
-#### time
63
140
@TODO: Write about this
64
141
65
-
#### `json`
142
+
-#### relativeTime
66
143
@TODO: Write about this
67
144
68
145
## API
69
146
70
-
### @TODO: `format`
147
+
### @TODO: `MessagePipe`
148
+
#### @TODO: `compile`
71
149
72
-
### @TODO: `formatRaw`
73
-
74
-
### @TODO: `getGlobalTransformers`
150
+
#### @TODO: `compileRaw`
75
151
76
152
## Framework integration
77
153
78
-
Works with React and Preact out of the box. Just swap out `format` with `formatRaw` and good to go. This works because it returns raw array of values that was the output of selectors and transformers.
154
+
Works with React and Preact out of the box. Just swap out `compile` with `compileRaw` and good to go. This works because it returns raw array of values that was the output of selectors and transformers.
Since we used `compileRaw`, library would output something like this: `['Hello ', [ReactElement], '!']`.
175
+
176
+
This will work with any kind of framework or custom library.
177
+
97
178
# Motivation
98
179
I was used to messageformat being the go to for this sort of stuff, but it has big flaws in the spec and library maintainers obviously wouldn't want to deviate from it. So the goal for messagepipe was to create NEW spec that solves all of the issues with it + must be faster & smaller.
99
180
100
-
One immediate flat that messagepipe solves is ability to select nested properties.
181
+
One immediate flaw that messagepipe solves is ability to select nested values.
0 commit comments