File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,6 +27,18 @@ The formatter name is converted to a formatter class name by:
2727
2828Arguments after the formatter name (separated by ` : ` ) are passed to the formatter's constructor.
2929
30+ ### Escaping Special Characters
31+
32+ If your formatter arguments contain special characters (` : ` or ` | ` ), you can escape them with a backslash:
33+
34+ - Escape colons in arguments: ` \: `
35+ - Escape pipes in arguments: ` \| `
36+
37+ ```
38+ {{placeholder|pattern:##\:##}} // Pattern with colon: 12:34
39+ {{placeholder|pattern:###\|###}} // Pattern with pipe: 123|456
40+ ```
41+
3042## Examples
3143
3244### Date Formatting
@@ -92,6 +104,25 @@ echo $formatter->format('Phone: {{phone|pattern:(###) ###-####}}');
92104// Output: Phone: (123) 456-7890
93105```
94106
107+ ### Escaping in Pattern Arguments
108+
109+ When your pattern contains special characters like ` : ` or ` | ` , escape them with a backslash:
110+
111+ ``` php
112+ $formatter = new PlaceholderFormatter([
113+ 'time' => '1234',
114+ 'value' => '123456',
115+ ]);
116+
117+ // Pattern with escaped colon
118+ echo $formatter->format('Time: {{time|pattern:##\:##}}');
119+ // Output: Time: 12:34
120+
121+ // Pattern with escaped pipe
122+ echo $formatter->format('Value: {{value|pattern:###\|###}}');
123+ // Output: Value: 123|456
124+ ```
125+
95126### Metric Formatting
96127
97128``` php
You can’t perform that action at this time.
0 commit comments