@@ -339,14 +339,19 @@ Below are two examples demonstrating how to use Liquid templates in Segment mapp
339
339
##### Example 1: Standardize email addresses
340
340
This example converts an email address to lowercase and removes extra whitespace, ensuring consistency for a destination.
341
341
342
- ``` json
343
- {% if event.properties.email % }
344
- {{ event.properties.email | downcase | strip }}
345
- {% else % }
346
- {{
event.properties.email | default: "[email protected] " }}
347
- {% endif % }
342
+
343
+ ```
344
+ {% raw %}
345
+ {% if event.properties.email %}
346
+ {{ event.properties.email | downcase | strip }}
347
+ {% else %}
348
+ {{ event.properties.email | default: "[email protected] " }}
349
+ {% endif %}
350
+ {% endraw %}
348
351
```
352
+
349
353
Input:
` event.properties.email ` = "
[email protected] "
354
+
350
355
351
356
352
357
Explanation:
@@ -358,18 +363,23 @@ Explanation:
358
363
##### Example 2: Transform phone number with conditional logic
359
364
This example formats a phone number by removing non-digit characters, adding a country code, and prepending a plus sign.
360
365
361
- ``` json
362
- {% if event.properties.phone % }
363
- {% assign phone = event.properties.phone | strip | remove: "-" | remove: "(" | remove: ")" | remove: " " % }
364
- {% if phone | slice: 0, 1 != "1" % }
365
- {% assign phone = phone | prepend: "1" % }
366
+
367
+ ```
368
+ {% raw %}
369
+ {% if event.properties.phone %}
370
+ {% assign phone = event.properties.phone | strip | remove: "-" | remove: "(" | remove: ")" | remove: " " %}
371
+ {% if phone | slice: 0, 1 != "1" %}
372
+ {% assign phone = phone | prepend: "1" %}
373
+ {% endif %}
374
+ {{ phone | prepend: "+" }}
375
+ {% else %}
376
+ {{ event.properties.phone | default: "" }}
366
377
{% endif %}
367
- {{ phone | prepend: "+" }}
368
- {% else % }
369
- {{ event.properties.phone | default: "" }}
370
- {% endif % }
378
+ {% endraw %}
371
379
```
380
+
372
381
Input: ` event.properties.phone ` = "(123) 456-7890"
382
+
373
383
Output: +11234567890
374
384
375
385
Explanation:
0 commit comments