Plain JavaScript. Declares every output page, decides which layout
partials get composited onto which page, and can
prepare presentation data for blocks. Required - a project with no
process.js, or one that never declares a page, generates nothing at all.
Runs after validate.js passes.
| Name | Type | Meaning |
|---|---|---|
inputs |
object | Same submitted-data map validate.js sees. A new or reassigned property forwards to every block. |
addPage(properties) |
function | Declares one output page - blank or backed by a PDF resource file. Page number = position in the call sequence. |
overlay(filename[, page]) |
function | Composites a partial onto page (default 1, an addPage()-declared page number). Callable more than once, targeting different pages. |
addPage({ width: 210, height: 297, backgroundColor: "#FFFFFF" }); // page 1
overlay("overlay.json");
if (inputs["is_certified"]) {
overlay("certified_badge.json"); // only when the checkbox is on
}
See JavaScript API for the full
function reference - addPage()/overlay()'s complete property/transform
shapes, plus every other available function (page refinement, project
introspection, formatting).
Handing computed data to blocks
Assign a new inputs property instead of writing a long formula
inline in a block:
inputs.gridData = [];
for (var i = 0; i < inputs.options.length; i++) {
var o = inputs.options[i];
inputs.gridData.push({ text: o.description }, { text: '$' + o.price });
}
A block then references it: "data": "inputs.gridData". See
Grid for the full pattern.
process.js and a block's own template run in separate scripting
contexts - the only bridge is inputs. A plain local variable
(var x = 5;) never reaches a block.