File tree Expand file tree Collapse file tree 1 file changed +26
-4
lines changed Expand file tree Collapse file tree 1 file changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,6 @@ I am Jane Doe!
7272``` csharp
7373Person person = new Person
7474{
75- Name = " John Doe" ,
7675 MyCars = new List <Car >
7776 {
7877 new Car { Make = " BMW" , Year = 2023 },
@@ -81,7 +80,6 @@ Person person = new Person
8180};
8281
8382string template = @"
84- {{ Name }}'s Cars
8583{{ #foreach(MyCars) }}
8684 - {{ Year }} {{ Make }}
8785{{ #endforeach }}" ;
@@ -93,13 +91,37 @@ Console.WriteLine(result);
9391
9492** Output:**
9593```
96- John Doe's Cars
9794 - 2023 BMW
9895 - 2020 Rolls-Royce
9996```
10097---
10198
102- ### Example 4: Number Formatting Support
99+ ### Example 4: Conditional Logic with ` #if ` , ` #else ` , and ` #endif `
100+
101+ ``` csharp
102+ Person person = new Person
103+ {
104+ Age = 40
105+ };
106+
107+ string template = @"
108+ {{ #if(Age >= 18) }}
109+ Adult
110+ {{ #else }}
111+ Minor
112+ {{ #endif }}" ;
113+
114+ string result = person .Map (template );
115+
116+ Console .WriteLine (result );
117+ ```
118+
119+ ** Output:**
120+ ```
121+ Adult
122+ ```
123+ ---
124+ ### Example 5: Number Formatting Support
103125
104126``` csharp
105127Car car = new Car
You can’t perform that action at this time.
0 commit comments