Object-to-template mapping for .NET with nested property support, loops, conditions, formatting, and lightweight calculations.
Use it when you need fast, readable template mapping for:
- Email and SMS templates
- Receipts, invoices, and reports
- Notification payloads
- Config and log rendering
- Direct property mapping:
{{ Name }} - Nested property mapping:
{{ Customer.BankingDetail.BankName }} - Collection loops:
{{ #foreach(Items) }}...{{ #endforeach }} - Conditional blocks:
{{ #if(Age >= 18) }}...{{ #else }}...{{ #endif }} - Built-in formatting for number/date/string
- XML escaping option (
XmlCharEscaping = true) - Calculation functions:
sum,avg,count,min,maxcalcarithmetic expressions
Install from NuGet:
Install-Package ObjectSemantics.NETusingObjectSemantics.NET;varperson=newPerson{Name="John Doe"};stringoutput=person.Map("Hello {{ Name }}");// Hello John Doevarpayment=newCustomerPayment{Amount=100000000,Customer=newCustomer{CompanyName="CRUDSOFT TECHNOLOGIES"}};stringresult=payment.Map("Paid Amount: {{ Amount:N2 }} By {{ Customer.CompanyName }}");// Paid Amount: 100,000,000.00 By CRUDSOFT TECHNOLOGIESstringtemplate="{{ #foreach(Items) }}[{{ Quantity }}x{{ Name }}={{ LineTotal:N2 }}]{{ #endforeach }}";stringtemplate="{{ #if(IsPaid == true) }}PAID{{ #else }}UNPAID{{ #endif }}";// Aggregates"{{ __sum(Customer.Payments.Amount):N2 }}""{{ _avg(Customer.Payments.PaidAmount):N2 }}""{{ __count(Customer.Payments.Amount) }}"// Arithmetic expression"{{ __calc(PaidAmount - Customer.CreditLimit):N2 }}"Detailed wiki files are available at the Wiki Page:
Contributions are welcome through issues and pull requests.