Defining Variables
In Frontmatter
Variables can be defined in YAML frontmatter at the top of your document:In Inputs
Some components create variables that can be used elsewhere in your markdown, for example the dropdown component. When you add an input component, it creates a variable using theid
attribute:
Using Variables
Reference variables using double curly braces{{ my_variable }}
. Variables defined in frontmatter use the $
prefix: {{ $my_variable }}
.
In Markdown
Use variables inline in your text content:From Frontmatter
From Inputs
In Component Attributes
Reference variables in component attributes with curly braces{{}}
:
From Frontmatter
From Inputs
In SQL
From Frontmatter
From Inputs
Use variables in SQL queries for dynamic filtering:Advanced Usage
Fallback Values
Add fallback values using pipes|
:
Conditional Blocks
Conditional blocks[[...]]
will only be included if all variables within it resolve to non-empty values:
Context-Aware Defaults
Input component variables automatically use context-aware defaults, so you can reference them directly without specifying a property:- In SQL contexts (SQL queries,
where
clauses): Uses.selected
(includes quotes) - In text contexts (titles, markdown text): Uses
.literal
(excludes quotes)
Explicit Property Reference
You can explicitly specify which property to use. Each filter component offers different properties. For example, the dropdown component offers.selected
, .literal
, and .filter
properties:
Nested Access
Use dot notation to access nested properties in frontmatter variables, and square brackets to access array indices:Data Types
Variables can be:- Strings:
name: John Doe
- Numbers:
age: 30
- Booleans:
active: true
- Arrays:
colors: [red, green, blue]
- Objects:
company: { name: Acme, industry: Manufacturing }