Handlebars set
Handlebars set: performs local variable assignment within the block scope.
Next
Runtime verified
Test scripts included
Performs local variable assignment within the block scope. Variables do not persist outside the block.
Syntax
{{#set ...assignments}}
…
{{/set}}
Returns string.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
assignments |
any | Yes, repeatable | Variable name/value pairs, e.g. name=”John” age=30. |
Example
Tested in a Marketing Cloud Next email on 2026-11-22:
{{#set greeting="Hi"}}{{greeting}}{{/set}}rendersHi, as documented.{{#set n=2}}{{add n 3}}{{/set}}renders5, as documented.
Show Next test script
Marketing Cloud Next
Works as documented
Every tested call rendered the documented result. Tested 2026-11-22 by rendering in a Marketing Cloud Next email.