forma
Translation status: English reader-locale proof. Term names and code fences follow the en pack; supporting prose may still be English.
Captured backtick templates for bound payloads.
Syntax: template(args)
Category#
literal
Related#
Examples#
radix/corpus/reference/literal/forma/forma.fab (canonical · literal)#
Captured backtick templates for bound payloads.
# =============================================================================
# forma — Captured backtick templates for bound payloads.
# =============================================================================
#
# What this teaches:
# • backtick template syntax `template`(args) — captures template text and parameters into the builtin `forma` class
# • indexed placeholders `§0` — an indexed hole selects its argument and may repeat with one value
# • templates without holes for static text
#
# Common mistakes:
# • Expecting template application to render the string inline — \`...\`(args) captures into a forma class, it does not interpolate into a string.
#
# See also: format, string
# =============================================================================
# Captured `forma` templates
#
# Backtick template application captures template text and parameters into the
# builtin `forma` class. It does not render holes into the template string.
#
# EXPECTED OUTPUT:
# Raw template text lines showing preserved § holes.
main {
let string tenantId ← "tenant-42"
let string plan ← "pro"
let forma q ← `
select id, email, plan
from accounts
where tenant_id = §
and plan = §
`(tenantId, plan)
print q.template
let forma indexed ← `where tenant_id = §0 or parent_tenant_id = §0`(tenantId)
print indexed.template
let forma bare ← `select 1`
print bare.template
}Expected output:
select id, email, plan
from accounts
where tenant_id = §
and plan = §
where tenant_id = §0 or parent_tenant_id = §0
select 1