Skip to content

Commit ad12e4b

Browse files
committed
chore: correct readme
1 parent edda7fd commit ad12e4b

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

  • src/mantle/evaluator/simple/expression

src/mantle/evaluator/simple/expression/README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ Within string literals, you can interpolate property values:
241241
"Height: ${height}m"
242242
```
243243

244+
**Note:** String interpolation only supports simple property names (without spaces). For properties with spaces or special characters, use concatenation instead (see below).
245+
244246
**Example:**
245247
```typescript
246248
const feature = {
@@ -254,6 +256,20 @@ const expr = new Expression('"Building: ${name}, Height: ${height}m"', feature);
254256
expr.evaluate(); // "Building: Building A, Height: 100m"
255257
```
256258

259+
**For properties with spaces, use concatenation:**
260+
```typescript
261+
const feature = {
262+
properties: {
263+
"building name": "Tower A",
264+
floors: 30,
265+
},
266+
};
267+
268+
// Use concatenation with + operator
269+
const expr = new Expression('${"building name"} + " has " + ${floors} + " floors"', feature);
270+
expr.evaluate(); // "Tower A has 30 floors"
271+
```
272+
257273
### Array Comparisons
258274

259275
The equality operators support checking if a value is in an array:
@@ -337,9 +353,9 @@ const expr2 = new Expression(
337353
);
338354
console.log(expr2.evaluate()); // #ff0000 (red)
339355

340-
// String interpolation
356+
// String concatenation (for properties with spaces)
341357
const expr3 = new Expression(
342-
'"${"building name"} has ${floors} floors"',
358+
'${"building name"} + " has " + ${floors} + " floors"',
343359
feature
344360
);
345361
console.log(expr3.evaluate()); // "Tower A has 30 floors"

0 commit comments

Comments
 (0)