Ir al contenido

Template syntax

Esta página aún no está disponible en tu idioma.

Variables are placeholders in your template that get replaced with actual data from your Lark Base records.

Use curly braces with the exact field name:

{Field_Name}

Examples:

  • {Customer_Name} → “Acme Corp”
  • {Invoice_Date} → “2024-01-15”
  • {Total_Amount} → “1,500.00”
Category Field types Default output
Text Plain text, Email, Barcode fields As-is
Number Numbers, Currency, Progress (%), Rating Lark-formatted (e.g. $1,234.56)
Date/Time Date, Created Time, Modified Time Lark-formatted (respects timezone setting)
Selection Single Select, Multi Select Text / comma-separated
People User, Created By, Modified By, Group Display name(s)
Contact Phone, URL Phone number / link URL
Checkbox Yes/No values true / false
Attachment Files and images See Dynamic images
Linked Records Access data from related tables See Linked records
Lookup Values pulled from linked records Resolved value
Formula Calculated fields (text, numbers, dates) Depends on result type

Access fields from linked records using dot notation:

{Customer.Name}
{Customer.Address}
{Customer.Email}

Nesting works up to 5 levels deep:

{Order.Customer.Company.Address.City}

Several field types expose sub-properties via dot notation. Without dot notation, they display a default value.

{Website} → "https://example.com" (the link URL)
{Website.text} → "Example Site" (the anchor text)
{Website.link} → "https://example.com" (the link URL)
{Assignee} → "John Doe" (display name)
{Assignee.name} → "John Doe"
{Assignee.en_name} → "John Doe" (English name)
{Assignee.id} → "ou_abc123" (Lark user ID)

For multi-person fields, use loops:

{#Assignees}
{name} ({en_name})
{/Assignees}
{Office} → "Headquarters, 123 Main St, City"
{Office.name} → "Headquarters"
{Office.full_address} → "123 Main St, City, Country"
{Office.address} → "123 Main St"
{Team} → "Engineering, Design" (comma-separated names)
{Team.name} → first group name (single-value only)
{Team.id} → first group ID (single-value only)

For multi-group fields, use loops:

{#Team}
{name} (ID: {id})
{/Team}

Multi Select fields can be looped or joined with a custom separator:

{Tags} → "Red, Blue, Green" (default comma-separated)
{Tags | join:" / "} → "Red / Blue / Green"
{#Tags}
- {.}
{/Tags}

Number and Date/Time fields display with Lark’s default formatting. When a filter is applied, it uses the raw value (actual number or epoch timestamp) and completely overrides Lark’s formatting:

{Price} → "$1,234.50" (Lark's format)
{Price | number:2} → "1,234.50" (raw number, re-formatted)
{Price | currency:"EUR":"de-DE"} → "1.234,50 €" (raw number, German locale)
{Date} → "2026/02/26" (Lark's format)
{Date | date:"DD MMM YYYY"} → "26 Feb 2026" (raw timestamp, re-formatted)

Fields without filters always display Lark’s original formatting.

For fields that link to multiple records, use loop syntax to repeat content for each item:

{#Line_Items}
Product: {Product_Name}
Quantity: {Quantity}
Price: {Price}
{/Line_Items}

{#Field} starts the loop, {/Field} ends it. Inside loops, use field names without the parent prefix.

You can use {/} instead of repeating the field name:

{#Line_Items}
{Product_Name} - {Price}
{/}

When loop tags are placed inside a table row, the entire row is duplicated for each item — perfect for line-item tables:

Product Qty Price
{#Line_Items} {Product_Name} {Quantity} {Price} {/Line_Items}

For arrays of simple values (not objects), use {.} to reference the current item:

{#Tags}
{.}
{/Tags}

Inside any loop, these special variables are available:

Variable Description Example
{$index} Current index (starts at 0) 0, 1, 2, …
{$num} Row number (starts at 1) 1, 2, 3, …
{$first} true for the first item Useful in conditionals
{$last} true for the last item Useful in conditionals

Loops can be nested. Inner loops can access fields from outer scopes:

{#Departments}
Department: {Name}
{#Employees}
{Name} works in {Department.Name}
{/Employees}
{/Departments}

If a field name exists in both the inner and outer scope, the inner scope takes priority.

Show or hide content based on field values.

Show content only if a field has a value:

{#if Discount}
Discount applied: {Discount}
{/if}

Show content only if a field is empty:

{#if !Notes}
No additional notes.
{/if}
{#if Status == "Approved"}
This invoice has been approved.
{/if}
{#if Status != "Draft"}
This document has been submitted.
{/if}

Filters let you transform how values are displayed using the pipe (|) syntax:

{Field | filterName}
{Field | filterName:"arg1":"arg2"}

Filters are applied after the value is retrieved and before it’s inserted into the document. If no filter is used, the value displays with its default Lark formatting.

Filter Description Example Output
upper Uppercase {Name | upper} ACME CORP
lower Lowercase {Name | lower} acme corp
capitalize Capitalize each word {Name | capitalize} Acme Corp
trim Remove leading/trailing whitespace {Name | trim} Acme Corp
truncate Truncate to length (default: 50) {Description | truncate:16} Lorem ipsum dolo...
pad Pad with character (default: 0) {$num | pad:3} 001

All number filters accept an optional locale for region-specific formatting:

Filter Args Example Output
number decimals, locale {Price | number:2} 1,234.50
number decimals, locale {Price | number:2:"de-DE"} 1.234,50
currency currency code, locale {Price | currency:"USD"} $1,234.50
currency currency code, locale {Price | currency:"EUR":"de-DE"} 1.234,50 €
currency currency code, locale {Price | currency:"JPY":"ja-JP"} ¥1,235
percent decimals, locale {Rate | percent:1} 45.6%
percent decimals, locale {Rate | percent:1:"de-DE"} 45,6 %

Format dates with custom patterns — useful when Lark’s built-in format doesn’t match your needs.

Syntax: {Field | date:"format":"timezone":"locale"}

All args are optional. Timezone defaults to UTC. Locale defaults to en-US.

Filter Args Example Output
date format, timezone, locale {Date | date:"DD MMM YYYY"} 26 Feb 2026
date format, timezone, locale {Date | date:"dddd, DD MMMM YYYY"} Thursday, 26 February 2026
date format, timezone, locale {Date | date:"DD MMMM YYYY":"UTC":"fr-FR"} 26 février 2026
date format, timezone, locale {Date | date:"dddd, DD MMMM YYYY":"UTC":"de-DE"} Donnerstag, 26 Februar 2026

Supported date tokens:

Token Output Example
YYYY 4-digit year 2026
MMMM Full month name (locale-aware) February, février, Februar
MMM Short month name (locale-aware) Feb, fév, Feb
MM 2-digit month 02
dddd Full weekday name (locale-aware) Thursday, Donnerstag, 木曜日
ddd Short weekday name (locale-aware) Thu, Do,
DD 2-digit day 26
HH 24-hour hour 15
mm Minutes 30
ss Seconds 00

Examples:

{Invoice_Date | date:"DD MMM YYYY"} → 26 Feb 2026
{Invoice_Date | date:"YYYY-MM-DD"} → 2026-02-26
{Invoice_Date | date:"MM/DD/YYYY"} → 02/26/2026
{Invoice_Date | date:"DD/MM/YYYY":"Asia/Tokyo"} → 26/02/2026 (in Tokyo timezone)
{Invoice_Date | date:"dddd, DD MMMM YYYY":"UTC":"ja-JP"} → 木曜日, 26 2月 2026
{Invoice_Date | date:"DD MMMM YYYY":"UTC":"id-ID"} → 26 Februari 2026
Filter Description Example Output
join Join array values (default: , ) {Tags | join:" / "} Red / Blue / Green
default Fallback for empty values {Phone | default:"N/A"} N/A

Filters can be chained left-to-right using multiple pipes:

{Name | trim | upper} → " hello " becomes "HELLO"
{$num | pad:3} → 1 becomes "001"
{Phone | default:"N/A" | upper} → null becomes "N/A"

Filters work with loop variables and the current item reference:

{#Items}
#{$num | pad:3} - {Name | upper}
{/Items}
{#Tags}{. | capitalize}, {/Tags}

Replace placeholder images with actual images from Lark attachment fields:

  1. Insert any image in your Word template (this is the placeholder).
  2. Right-click the image → Edit Alt Text.
  3. In the Alt Text description, type {FieldName}.
  4. Save your template.

The placeholder image will be replaced with the actual image from the attachment field, preserving the placeholder’s size.

For fields with multiple attachments, use index notation:

{Photo} → First image (same as {Photo[0]})
{Photo[1]} → Second image
{Photo[2]} → Third image

For fields with a variable number of attachments, use loop syntax with {.} as the image alt text. Each attachment expands its own copy of the placeholder:

{#Product_Photos}
[image with alt text: {.}]
{/Product_Photos}

In a table, each attachment gets its own row:

# Photo Filename
{#Product_Photos} {$num} [image alt: {.}] {name} {/Product_Photos}

Available properties inside the loop:

Variable Description Example
{name} Filename photo1.jpg
{type} MIME type image/jpeg
{size} File size in bytes 204800

Image placeholders work inside loop blocks. Each iteration resolves the image for that item:

{#Employees}
Name: {Name}
Photo: [image with alt text: {Photo}]
{/Employees}

Generate QR codes and barcodes from field values. Set up the same way as dynamic images — via image Alt Text.

{QR:FieldName}

Example: {QR:Order_ID} generates a QR code containing the Order_ID value.

Syntax Type Notes
{BARCODE:FieldName} Code128 Default, alphanumeric
{BARCODE128:FieldName} Code128 Explicit Code128
{BARCODE39:FieldName} Code39 Uppercase + digits only
{BARCODEEAN13:FieldName} EAN-13 13-digit retail product code
{BARCODEEAN8:FieldName} EAN-8 8-digit short-form EAN
{BARCODEUPCA:FieldName} UPC-A 12-digit North American retail
{BARCODEUPCE:FieldName} UPC-E Compressed UPC
{BARCODEITF14:FieldName} ITF-14 Shipping / carton codes
{BARCODEDATAMATRIX:FieldName} DataMatrix 2D, high density
{BARCODEPDF417:FieldName} PDF417 2D, stacked linear

The prefix is case-insensitive — {qr:Field} and {QR:Field} both work.

All placeholder syntax works in document headers and footers, just like in the main body.

Common uses:

  • Company name or logo in the header
  • Document ID or date in the footer
  • Dynamic labels like Invoice for {Customer_Name}

To add placeholders: Insert → Header/Footer → Edit → type your placeholder like {Field_Name}.

Syntax Description
{Field} Simple variable
{Field.Nested} Linked record field (dot notation)
{URL.text} / {URL.link} URL sub-properties
{User.name} / {User.en_name} / {User.id} User sub-properties
{Location.name} / {Location.full_address} Location sub-properties
{Group.name} / {Group.id} Group sub-properties
{#Field}...{/Field} Loop over multi-value field
{/} Shorthand close (closes nearest open loop)
{.} Current item in loop (for primitive arrays)
{$index} Loop index (0-based)
{$num} Row number (1-based)
{$first} / {$last} First/last item boolean
{#if Field}...{/if} Conditional (truthy)
{#if !Field}...{/if} Conditional (falsy)
{#if Field == "val"}...{/if} Conditional (equality)
{#if Field != "val"}...{/if} Conditional (inequality)
{Field | upper} Filter: uppercase
{Field | lower} Filter: lowercase
{Field | capitalize} Filter: capitalize words
{Field | trim} Filter: strip whitespace
{Field | truncate:30} Filter: truncate with ellipsis
{Field | pad:3} Filter: zero-pad
{Field | number:2} Filter: number with decimals
{Field | number:2:"de-DE"} Filter: localized number
{Field | currency:"USD"} Filter: currency formatting
{Field | currency:"EUR":"de-DE"} Filter: localized currency
{Field | percent:1} Filter: percentage
{Field | date:"DD MMM YYYY"} Filter: custom date format
{Field | date:"dddd, MMMM DD":"UTC":"fr-FR"} Filter: localized date
{Field | join:" / "} Filter: join array with separator
{Field | default:"N/A"} Filter: fallback value
{Field | trim | upper} Chained filters (left-to-right)
{Photo} / {Photo[1]} Image (via Alt Text)
{QR:Field} QR code (via Alt Text)
{BARCODE:Field} Barcode (via Alt Text)