# Template renderer

Fill a Mustache-style template with JSON data: {{name}} values, {{#list}} loops and {{^empty}} fallbacks.

- Endpoint: `POST https://setget.net/v1/tools/template-render` with JSON `{"input": {...}}`
- MCP: `run_tool` with `slug` = `template-render`
- Page: https://setget.net/tools/template-render

## Inputs

- `template` (required, string): The template text.
- `data` (required, json): The values to fill in, as a JSON object.
- `escape` (optional, boolean, default `true`): HTML-escape {{name}} values. {{{name}}} is never escaped.

## Example 1

```json
{"input":{"template":"Hello {{name}}!\n{{#items}}\n- {{title}} ({{price}})\n{{/items}}\n{{^items}}\nNothing here.\n{{/items}}","data":{"name":"Sam & Co","items":[{"title":"Tea","price":3},{"title":"Cake","price":4.5}]}}}
```

Result:

```json
{"text":"Hello Sam &amp; Co!\n- Tea (3)\n- Cake (4.5)\n"}
```

## Example 2: Dotted names, raw output and a comment

```json
{"input":{"template":"{{user.name}} wrote {{{html}}}{{! not shown }}","data":{"user":{"name":"Ada"},"html":"<b>3</b>"}}}
```

Result:

```json
{"text":"Ada wrote <b>3</b>"}
```

## Example 3: A list of plain values

```json
{"input":{"template":"{{#tags}}[{{.}}]{{/tags}}","data":{"tags":["a","b"]}}}
```

Result:

```json
{"text":"[a][b]"}
```

**Which Mustache features work?** Variables, {{{raw}}} and {{&raw}} output, dotted names, sections over lists and true values, inverted sections and comments. Partials, lambdas and custom delimiters are not supported.

**What counts as false for a section?** false, null, 0, empty text, an empty list, an empty object and a missing name. {{^name}} shows its content in exactly those cases.

**What happens when a name is missing from the data?** Nothing is printed for it. No error is raised.

**Why did "&" turn into "&amp;"?** Values are HTML-escaped by default. Set escape to false for plain text, or use {{{name}}} for one value.
