Skip to content

Syntax Reference ​

Folio templates use a small, predictable grammar. Whitespace is flexible, statements are separated by newlines or semicolons, and blocks are wrapped in braces.

Variables ​

Declare variables with a default value. These defaults are merged with the data array passed at render time; data values override defaults.

folio
var title = "Default Title"
var total = 0.00

Use prop for values that are required from the caller:

folio
prop title

Comments ​

Single-line comments start with //:

folio
// This line is ignored
heading "Title"

Strings ​

Use double quotes for string literals:

folio
text "Hello, world"

Multiline strings are not supported. For long text, concatenate by placing multiple text elements in sequence.

Numbers ​

Numeric values default to points. Explicit units are supported for lengths:

folio
var padding = 20      // 20 pt
var width = 50%       // 50% of container
var margin = 10pt

Expressions ​

Expressions support comparison, logical operators, and dot notation for array/object properties:

folio
if total > 100 { ... }
if enabled && visible { ... }
if user.role == "admin" { ... }

Blocks ​

Elements and control-flow statements use braces for children:

folio
page {
  column {
    heading "Title"
    text "Body"
  }
}

Page Presets ​

folio
page { ... }
page(size=a3) { ... }
page(size=letter, orientation=landscape) { ... }
page(size="600x800") { ... }
AttributeValuesDefault
sizea4, letter, a3, "WxH"a4
orientationportrait, landscapeportrait

Attributes ​

Elements accept attributes inside parentheses. Attribute values can be strings, numbers, booleans, or identifiers:

folio
heading(color="#1e293b", fontSize=18) "Styled Heading"
column(padding=20, margin=10) { ... }
text(align=center, fontWeight=bold) "Centered bold text"

Attribute Reference ​

Common attributes across elements:

AttributeTypePurpose
paddingnumberInner spacing
marginnumberOuter spacing
colorhex or nameText color
fontSizenumberText size in points
fontWeightnormal, boldText weight
alignleft, center, right, justifyText alignment
backgroundhex or nameBackground color
widthnumber or percentElement width
heightnumber or percentElement height

Variable Interpolation ​

Variables are referenced by name. Folio does not use embedded string interpolation; instead, place a text element where you want the value:

folio
var customer = "Jane Smith"

text "Customer:"
text customer

This keeps the template structure consistent and avoids escaping surprises.

Engineered for teams that care about predictable PDF output.