Simple Tags

{Expression} resolves the expression against local scope and replaces the tag with the string result.

Single-property bind

var ngin = new TemplateEngine("Hello {FirstName} {LastName}, this is just a test.");
string result = ngin.Merge(new { FirstName = "John", LastName = "Doe" });
// Hello John Doe, this is just a test.

Compound bind expressions

Dotted expressions traverse nested objects. The maximum depth is 16 levels — exceeding it throws RecursionStackDepthException.

Data:
var person = new
{
    Name = new { First = "John", Last = "Doe" },
    Address = new { City = "Dallas", State = "TX" }
};
Template:
Hello {Name.First}, we see you currently live in {Address.City}, {Address.State}.
Result:
Hello John, we see you currently live in Dallas, TX.

What can be bound

The engine resolves via reflection:

  • Properties — public instance properties
  • Fields — public instance fields
  • Dictionary entries — string keys on any IDictionary

Static members, methods, and indexers are not supported. Use a registered lambda for values that require computation.

Missing members throw. A tag referencing a property, field, or key that does not exist on the bound object raises a MergeException — the engine does not silently return empty string. Model possibly-absent values as null and guard with {#if}.

Lambda calls

A simple tag can invoke a registered lambda instead of a bind expression:

{ (FirstName, LastName) => formatName }

See Lambda Expressions for the full call syntax and registration.

Next steps

  • Conditionals — branch on truthy/falsy values
  • Iteration — render a block per item in a collection
  • With Blocks — shift local scope to reduce dotted repetition