Skip to main content

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​

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​

Source: packages/core/src/layers/template.ts:154