# Fields ({{ }})

> Write changing values as {{name}}; each data row prints one label.

Source: https://82label.app/en/docs/fields/

Put `{{name}}` anywhere in text, barcode values, QR values and image sources. At print time it is replaced with the value of the same name in your data. Mix it with fixed text freely: `'Order {{orderNo}} · {{qty}} pcs'`.

```js
const template = {
  v: 1,
  name: 'Price tag',
  paper: { kind: 'roll' },
  label: { width: 40, height: 30 },
  elements: [
    { type: 'text', x: 2, y: 2, w: 36, h: 8, text: '{{name}}', size: 9, bold: true, fit: 'wrap' },
    { type: 'text', x: 2, y: 10, w: 36, h: 7, text: '₩{{price}}', size: 14, bold: true, align: 'right' },
    { type: 'barcode', x: 2, y: 18, w: 36, h: 10, format: 'ean13', value: '{{ean}}' },
  ],
};

const rows = [
  { name: 'Organic milk 900ml', price: '3,480', ean: '880123456789' },
  { name: 'Whole wheat bread', price: '4,200', ean: '880123456790' },
];

Label82.print(template, rows);
```

## Data

- `rows` in `print(template, rows)` is one object or an array. Each array item prints one label.
- Values are strings or numbers. `null`, `undefined` and missing names print as empty.
- Values go in as text only (never parsed as HTML or SVG), so customer-typed addresses are safe to pass as they are.
- The same label several times: `{ copies: 3 }` prints three of each row. A different count per row: `{ qtyField: 'qty' }` (that column's number).

## Field list and example values

The designer collects the `{{ }}` in a template into a field table and stores example values in `fields`. Previews without data use them.

```js
import { extractFields, exampleRow, fill } from '@82label/core';

extractFields(template); // ['name', 'price', 'ean']
exampleRow(template);    // { name: '…', price: '…', ean: '…' } (fields[].example, else the name)
fill('{{name}} ₩{{price}}', { name: 'Milk', price: '3,480' }); // 'Milk ₩3,480'
```

Formats such as `{{price|won}}` and `{{date|date:YYYY.MM.DD}}`, serial numbers `{{seq:0001}}` and dates `{{today+365}}` are in [Value formats, serial numbers, dates](https://82label.app/en/docs/formats/). To print from a spreadsheet without code, see [Bulk printing](https://82label.app/en/docs/bulk/).

> Field names may be Korean (`{{상품명}}`), but ASCII names are easier to handle in code.
