# formatTemplate

Fills a card or list template from a feature's fields, through the named
formatters. A field that is missing, null or unreadable by its formatter
becomes an empty string; when every field the template names is like that,
the result is null, so the caller can leave the line out. An unknown
formatter writes the value as plain text.

This is a function exported by `@mapcairn/core`, checked against version 0.2.0.

## Signature

```ts
import { formatTemplate } from "@mapcairn/core";
 
function formatTemplate(template: LayerTemplate, fields: Readonly<Record<string, FieldValue>>, formatters: FormatterRegistry, context: FormatContext): string | null;
```

## Parameters

- `template` (`LayerTemplate`)
- `fields` (`Readonly<Record<string, FieldValue>>`)
- `formatters` (`FormatterRegistry`)
- `context` (`FormatContext`)

## Returns

`string | null`

## See also

- [`LayerTemplate`](https://docs.mapcairn.com/api/core/LayerTemplate.md)
- [`FieldValue`](https://docs.mapcairn.com/api/core/FieldValue.md)
- [`FormatterRegistry`](https://docs.mapcairn.com/api/core/FormatterRegistry.md)
- [`FormatContext`](https://docs.mapcairn.com/api/core/FormatContext.md)

Source: [packages/core/src/layers/template.ts:154](https://github.com/MapCairn/mapcairn/blob/main/packages/core/src/layers/template.ts#L154)
