Basic

What a generator is for

A generator takes content and writes pages. The writing is the whole point, and the point is that the pages are files before they are served.

What you will see

Two lines. Zero work at serve is the claim.

About 1 min of reading

Try It

Write the triple

1

Write the input

printf 'title=Hello body=world\n' > /tmp/c.txt; cat /tmp/c.txt

Before you run it, say out loud what it will print. Then open the answer.

What it prints
One line with a shape. The shape is written down, which is the claim.
2

Write the output

printf '

Hello

\n

world

\n' > /tmp/p.html; wc -c < /tmp/p.html

Before you run it, say out loud what it will print. Then open the answer.

What it prints
A byte count. The page is a file, which is the output.
3

Write the cost

printf 'build 1\nserve 0\n' > /tmp/k.txt; cat /tmp/k.txt

Before you run it, say out loud what it will print. Then open the answer.

What it prints
Two lines. Zero work at serve is the claim.

Data Flow

Content to files
1 The content is read with its shape
↓
2 The templates give the pages a shape
↓
3 The pages are written as files
↓
4 The server hands out the files
Why this works
Why nothing runs at serve time

A page that runs is a page that can fail. A page that is a file cannot fail, and cannot fail is the claim.

The claim of this subject

Content in, files out, one build. That triple is what every later lesson shapes.

Examples

The input is content

Content is data with a shape. A shape that is written down is a shape a reader can change.

The output is files

Files, not answers. Files are what a server can hand out without asking the generator.

The build is the cost

The cost is paid once at build. Paying once is what makes serving free.

Next Lesson
Content as data with a shape
Content as data with a shape →