Define page-level data, use variables to inject values into your HTML, and access built-in page metadata. This is what makes your static pages dynamic.
A data block is a <script data> tag at the top of your .orb page that defines the page's data as a JavaScript object.
<script data>
({
title: "Home",
author: "Dan",
year: 2026,
showBanner: true
})
</script>
<layout src="main.layout">
<content>
<h1>{{ title }}</h1>
<p>By {{ author }}, {{ year }}</p>
</content>
</layout>
Important: The data must be wrapped in ({ ... }) — an object literal inside parentheses. This is how OrbLayout safely evaluates it.
Use {{ variableName }} anywhere in your page to inject data values.
<!-- In text content -->
<h1>{{ title }}</h1>
<!-- In attributes -->
<img src="{{ imageUrl }}" alt="{{ imageAlt }}" />
<!-- In CSS -->
<div style="color: {{ textColor }}">...</div>
<!-- Mixed with text -->
<p>Copyright © {{ year }} {{ author }}</p>
Variables work everywhere — text content, HTML attributes, inline styles, even inside component props.
<script data>
({
// Strings
name: "OrbLayout",
// Numbers
version: 1.2,
count: 42,
// Booleans (for conditionals)
showBanner: true,
isAdmin: false,
// Arrays (for loops)
tags: ["html", "css", "static"],
// Objects (for {{#with}} scoping)
author: {
name: "Dan",
twitter: "@dan"
},
// Array of objects (for rich loops)
features: [
{ name: "Fast", desc: "Zero runtime" },
{ name: "Simple", desc: "Just HTML" }
]
})
</script>
| Type | Example | Used With |
|---|---|---|
| String | "Hello" | {{ variable }} |
| Number | 42 | {{ variable }}, filters |
| Boolean | true / false | {{#if}}, {{#unless}} |
| Array | ["a", "b"] | {{#each}} |
| Object | { name: "Dan" } | {{#with}} |
Access nested properties with {{#with}} blocks (covered in Lesson 8):
<script data>
({
company: {
name: "Acme Inc",
founded: 2020,
ceo: "Alice"
}
})
</script>
{{#with company}}
<h2>{{ name }}</h2>
<p>Founded: {{ founded }}</p>
<p>CEO: {{ ceo }}</p>
{{/with}}
OrbLayout provides built-in variables that are always available — no data block needed.
| Variable | Output | Description |
|---|---|---|
{{ @page.filename }} | index | Current page filename (no extension) |
{{ @page.date }} | 2026-03-04 | Today's date (YYYY-MM-DD) |
{{ @page.year }} | 2026 | Current year |
<footer>
<p>© {{ @page.year }} My Website</p>
<p>Last built: {{ @page.date }}</p>
<p>Page: {{ @page.filename }}</p>
</footer>
Use case: {{ @page.year }} in a footer component means you never have to update the copyright year manually!
Understanding how data flows is crucial:
<script data> ← You define data here
│
▼
Page (.orb) ← Variables are resolved in the page
│
▼
Layout (.layout) ← Variables flow into the layout too
│
▼
Components (.orb) ← Components get data via props
{{ title }}{{ title }} works in layoutsKey rule: Components are isolated. To pass data to a component, use props: <use component="card" title="{{ title }}" />
You should now understand:
<script data>({ ... })</script>{{ variableName }}@page.* variables for metadata