Basic Field Output
{{name}} is {{age}} years old and works as {{job or "unemployed"}}
Number Formatting
Price: ${{%price}} | Large Number: {{~bigNumber}}
Default Values & Safety
{{username or "Guest"}} | {{profile.bio or "No bio available"}}
Field Output API
Basic Syntax
{{field}} → Safe HTML output
{{{field}}} → Raw HTML output
{{:variable}} → Direct variable
{{field or "default"}} → With fallback
Number Formatting
{{%number}} → 2 decimal places
{{~number}} → Rounded (1k, 1M)
Examples
// Basic field output const template = Macrobars.compile('{{name}}'); const result = template({name: 'John'}); // With defaults const withDefault = '{{title or "Untitled"}}'; // Number formatting const price = '${{%cost}}'; // $12.34 const count = '{{~views}}'; // 1.2k