Google Docs Function - Template Guide
________________

With the Google Docs Function, you can create custom templates inside Google Docs using your Airtable data. The Google Docs Function contains templates including: Tables, Text, Numbers, Dates, Images, Links, and Grids

This approach allows the most flexible templating system for Airtable. Use your data inside Google Docs and customize it with dynamic formatting, such as tables, paragraphs and headings, date and number formatting, and more.

The templates use a syntax called Handlebars. You can create Simple or Complex templates.

**Simple Templates: **{{template-type options....}}
**Complex templates with inner body:** {{#template-type options...}} {{ inner-types }} {{ /template-type }}

In this article

Airtable Configuration
Formatting Template Parameters

Template Types
Field Placeholder
Table
Image
Link
Content (text, numbers, dates)
Grid

Advanced
More Examples

_________________

Airtable Configuration

The easiest way to insert your data is to use Lookup fields in your base. Create a lookup field for each set of values you want from your base.

Example: You have a secondary table in your base called People with the primary field called Name. You have 3 records in the table. You have a record for Larry, a record for Mo, and a record for Curly. In your main table called Clients, you need to add a Lookup field that looks up the People table and the Name field. Once your template table is set up, each record will be inserted to a column.

Once you set up your Table source and a Lookup field, you can then reference any field from the secondary table in your base inside your template table in Google.

_________________

Formatting Template Parameters

To format the templates, add the template type name, then a space followed by an =. Finally, surround your data or formatting in parentheses.

Example:

{{date value="{{Airtable date field name}}" pattern="YYYY-MM-DD"}}

date - template type
value= - parameter
"{{Airtable date field name}}" - value




_________________

Templates
________________

Field Placeholder

{{Your Field Name}} - These are used to insert your data anywhere in the file. Wrap your data in 2 curly brackets.

________________

Table

You can create a table that is dynamically generated based on the exact size you need to fit your data. It will stretch across multiple tables when needed.

Table Configuration

The easiest way to insert your data is to use Lookup fields in your base. Create a lookup field for each set of values you want from your base.

Example: You have a secondary table in your base called People with the primary field called Name. You have 3 records in the table. You have a record for Larry, a record for Mo, and a record for Curly. In your main table called Clients, you need to add a Lookup field that looks up the People table and the Name field. Once your template table is set up, each record will be inserted to a column.

Once you set up your Table source and a Lookup field, you can then reference any field from the secondary table in your base inside your template table in Google.

Table Syntax

{{table source=" | "}} {{ /table }} - Insert your field names for each column of the table
{{#table source}} - Your table name in Airtable

Example:

{{table source="Template Names|Template Ages”}}
{{#table source=”Table Data” borders=”sides: none” columnWidths=”0.7,3,,,1”}}


Options:
source - Field Name of the Data Source(s). Supports following field types: MultiSelect, Lookup, Rollup, Record Link
Field Type Details:
MultiSelect - Should be used alone and not combined with other source values
Lookup - Can use multiple Lookup fields (separated by the | character by default) - must be lookups on the same table and not use any conditional selection to avoid misplaced values
Rollup - For rollups, use an ARRAYJOIN function and pass the | character as 2nd parameter to separate values. ex: ARRAYJOIN(values, "|")
Record Link - For Linked Record Fields, enter the linked record field in the source parameter, then use a fields parameter either in the table template or an inner body template

fields - Only use with a Record Link Field, set to use the fields within a linked table. Separate fields with | character by default
ex: {{table source="Linked Field" fields="Name|Status|Attachments"}}

borders - borders are on by default.
To remove borders: {{table borders="sides: none"}}
To have top/bottom borders only: {{table borders="sides:top,bottom; color:#FFFFFF; width:0.5; dashStyle:solid"}}
To set dashed borders on all: {{table borders="sides:all; color:#FFFFFF; width:0.5; dashStyle:dash"}}

columnWidths - set your column widths in inches
ex: {{table columnWidths="0.5,1,1"}}
Note: to allow a column to use remaining, leave blank. Ex: {{table columnWidths="1,,1"}} will set 1st and 3rd columns to 1 inch, and 2nd will use remaining

sort - sort the table data prior to display.
ex: {{table sort="field: Name; order:asc"}}
field - the field name to use for sorting purposes
order - (asc|desc) Either ascending (asc) or descending (desc)

separator - set to a value to use for determining how source and fields parameters are separated
ex: {{table source="Field A,Field B" separator=","}}

weightedFontFamily - change the font and weight of font of the text
ex: {{table weightedFontFamily=”fontFamily: ZCOOL KuaiLe; weight: 600”}}
fontFamily - Select from available Google Fonts
weight - Value between 100 and 900 to determine the weight (i.e. thickness) of the font. 400 is default

fontSize - the size of the font, in inches
ex: {{table fontSize="14"}}
______

Advanced Table Usage: (Work in Progress - contact support if looking to do more advanced table use case)

{{#body}}{{/body}} - Determines the display inside the table cells

Example: {{#body evenColor=”#FFFFFF” oddColor=”#0A0A0A” oddFgColor=”#FFFFFF”}}
{{cell field=”Name”}}
{{cell field=”Image” type=”image” index=”first” size=”width: 3”}}
{{cell field=”Notes”}}
{{cell field=”Url” type=”link” labelField=”Name”}}
{{#cell type=”text”}}
{{text value=”Name: ”}}{{text field=”Name”}}{{text value=”\n”}}
{{text value=”Notes: ”}}{{text field=”Notes”}}{{text value=”\n”}}
{{/cell}}
{{/body}}


Options:
evenColor - use HTML Hex color codes
oddColor - use HTML Hex color codes
oddFgColor - Foreground color of each odd row - use HTML Hex color codes
evenFgColor - Foreground color of each even row - use HTML Hex color codes

{{cell field="Your Airtable Field Name"}} - Used to determine which field in Airtable is used

Example: {{cell field=”Notes”}}
OR
{{cell field=”Image” type=”image” index=”first” size=”width: 3”}}


Options:
labelField - add a name for the link (instead of displaying the entire URL)
foregroundColor - use HTML Hex color codes

{{#cell type}} - you can use text, image, and link

**Text** Options:
{{text value="static text"}} - any static text value you want to use in your table. This value never changes. You can also use formatting such as \n to create separate lines.
{{text field="Your Airtable field name"}} - what you want displayed in the table field. Typically, this will be Your Airtable Field Name

Example:

{{table source="Template Names|Template Ages”}}

{{#table source=”Table Data” borders=”sides: none” columnWidths=”0.7,3,,,1”}}

{{#body evenColor=”#FFFFFF” oddColor=”#0A0A0A” oddFgColor=”#FFFFFF”}}
{{cell field=”Name”}}
{{cell field=”Image” type=”image” index=”first” size=”width: 3”}}
{{cell field=”Notes”}}
{{cell field=”Url” type=”link” labelField=”Name”}}
{{#cell type=”text”}}
{{text value=”Name: ”}}{{text field=”Name”}}{{text value=”\n”}}
{{text value=”Notes: ”}}{{text field=”Notes”}}{{text value=”\n”}}
{{/cell}}
{{/body}}

{{/table}}

________________

Image

Insert images in a specific location in your document

There are 2 ways to insert images - with a Placeholder or with the {{Image field}} parameter

To use images with a Placeholder:
Create a general placeholder image
Insert your placeholder image into your document
Right-click your image and choose Alt Text
In the Title field, add the name of your Airtable Field Name surrounded by brackets
Example: {{My Airtable Field Name}}

To use images with the {{image field}} parameter:
Use {{image field=" "}}
Add your Airtable field name in the parentheses

Options:
index - determines which order the image will be pulled from. Use first, random, last, or the specific index value (the first will be index 0)
size - use height and/or width and then specify in inches. If only one is set, the other dimension will be determined by the original image dimensions ratio
ex: {{image size="width: 6.5; height: 4"}}
url - will make the image a link to the specified URL

Examples:
{{image field="Attachments" index="random" size="width: 5"}} - select a random attachment and fix width to 5 inches
{{image field="Attachments" index="first" url="{{URL}}"}} - select first attachment item and make it a link to the value in the URL field

________________

Link

This is used to insert your Airtable data as a link inside your document

{{link field="Your Airtable Field Name"}} - the name of the Airtable field that contains what you want to link
{{link url=" "}} - the url for what you want to link

Options:
labelField - add a name for the link (instead of displaying the entire URL)
foregroundColor - use HTML Hex color codes

________________

Content

Paragraph (Coming Soon)

{{ #p }} {{ /p }} - Creates a paragraph

Options:
shading -



Heading

{{#heading level="title"}} {{ /heading }} - Creates Headings

level - The heading level. Valid options: title|subtitle|1|2|3|4|5|6


Number

{{ number }}

Number field - Format data as a number

Options:

format - determines your number format - example - 0.00. View available format options
field - your Airtable field name



Date

{{ date }}

Date field - Format data as a date

Options:

format- use date formatting (i.e. YYYY-DD-MM). View full date formats
field - your Airtable field name
________________

Grid

Adds all data from a field, linked table and will generate a grid table where everything is added. Most parameters from table are valid here and won't be repeated. View Table documentation for styling parameters

{{ #grid }} {{ /grid }}

Options:
type - The grid cell type. Available options: text|image|link|number|date
width - The width of each grid cell
columns - you specify how many columns to be used in the grid
Default: 3 columns

Example:
{{#grid source=”Logo” type=”image” size=”width: 1.5” columns="2" max="10" sort="Name"}}
{{/grid}}


_____________________________

Advanced

Conditional Formatting

ifEq - only display when the data from this field is equal to a certain value. This parameter needs to be your Field Name in Airtable.
ifVal - only display if this value is present. This parameter needs to be a specific Value from the Field Name you chose.

Example: {{link field=”Record Link” foregroundColor=”#FF0000” ifEq=”Name” ifVal=”Client A”}}

_____________________________

More Examples

These examples shows some ways to utilize the templates in your Docs

{{table source="Template Names|Template Ages”}}

{{#table source=”Table Data” borders=”sides: none” columnWidths=”0.7,3,,,1”}}

{{#body evenColor=”#FFFFFF” oddColor=”#0A0A0A” oddFgColor=”#FFFFFF”}}
{{cell field=”Name”}}
{{cell field=”Image” type=”image” index=”first” size=”width: 3”}}
{{cell field=”Notes”}}
{{cell field=”Url” type=”link” labelField=”Name”}}
{{#cell type=”text”}}
{{text value=”Name: ”}}{{text field=”Name”}}{{text value=”\n”}}
{{text value=”Notes: ”}}{{text field=”Notes”}}{{text value=”\n”}}
{{/cell}}
{{/body}}

{{/table}}

{{link field=”Record Link” foregroundColor=”#FF0000” ifEq=”Name” ifVal=”Client A”}}

{{#p shading=”backgroundColor: #FF0000”}}
This is the last paragraph for {{Name}}
{{/p}}

{{#heading level=”title”}}My First Title{{/heading}}

{{number field=”Number” format=”0.00”}}
{{date field=”Date” format=”YYYY-DD-MM”}}

{{#grid source=”Template Names”}}
{{/grid}}

{{image field=”Logo” index=”random” size=”width: 6.5”}}

{{#grid source=”Logo” type=”image” size=”width: 1.5”}}
{{/grid}}

My Name is: {{Name}}


****______

_____________________________

Advanced
For Advanced Users. View possible parameter options for the following:
Text Style
Dash Styles
Table Cell Styles
Table Cell Borders
Table Column Properties
Weighted Font Family
Supported Fonts
Was this article helpful?
Cancel
Thank you!