# `gno.land/p/nym-moultest123/template` A small `{{ }}` template engine for building Markdown in a realm, with the [`p/moul/md`](../md) helpers available as template functions. ```go r := template.NewRenderer() out := r.Render("{{H1 title}}\n\n{{Bold name}} has {{count}} items", map[string]interface{}{ "title": "Report", "name": "moul", "count": 3, }) ``` ## Syntax | form | meaning | | --- | --- | | `{{key}}` | substitute a value from the data map | | `{{Func arg}}` | call a template function | | `{{range items}} ... {{end}}` | iterate | | `{{if cond}} ... {{else}} ... {{end}}` | conditional | | `{{- x}}`, `{{x -}}` | trim whitespace on that side | Whitespace trimming matters more here than in Go's `text/template`, because the output is Markdown and a stray blank line changes the rendering. ## Built-in functions Markdown, forwarded to `p/moul/md`: `H1` to `H6`, `Bold`, `Italic`, `Strikethrough`, `InlineCode`, `CodeBlock`, `LanguageCodeBlock`, `Blockquote`, `Paragraph`, `BulletItem`, `TodoItem`, `HorizontalRule`, `Link`, `Image`, `InlineImageWithLink`, `Footnote`, `CollapsibleSection`, `EscapeText`. General: `concat`, `printf`, `trim`, `string`, `index`. Register your own with the `Func` signature: ```go type Func func(args ...string) string ``` ## Why not `text/template` It is not in the gno standard library, and it would not fit: it reaches for reflection, and template execution has to stay cheap and bounded when it runs inside a `Render`. This engine is string in, string out, with an explicit function table and no reflection. `Helper` is kept as an alias for backward compatibility; new code should use `Func`. --- Part of **[moul/gno-contracts](https://github.com/moul/gno-contracts)** — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage. **Dependency graph:** ![gno.land/p/nym-moultest123/template/v0 dependency graph](https://raw.githubusercontent.com/moul/gno-contracts/main/_assets/gno.land/p/nym-moultest123/template/v0/deps.png) > ⚠️ **Disclaimer:** provided as-is, without warranty; not security-audited. Full disclaimer: [DISCLAIMER](https://github.com/moul/gno-contracts/blob/main/DISCLAIMER.md).