Back to Knowledge Base
How to Create Templates
What are Templates?
Section titled “What are Templates?”Templates are saved text documents — typically JDF or JMF formatted — that can be rendered with dynamic data at runtime. They are used for generating job tickets sent to print equipment.
Template types
Section titled “Template types”| Type | Use case |
|---|---|
| JDF Template | Job Definition Format tickets for CIP4-compatible machines |
| JMF Template | Job Messaging Format messages for press control |
How to create a Template
Section titled “How to create a Template”- Go to Menu → Developer → Templates
- Click + New Template
- Enter a Name and select the Type
- Write the template — use
{{variable}}syntax for dynamic values - Click Save
Rendering a Template
Section titled “Rendering a Template”Render a template with the renderTemplate GraphQL mutation — by its handle, passing
a JSON context string with the values your {{variable}} placeholders reference. From a
Workflow Script node:
local res = ctx.graphql.query([[ mutation($tpl: RenderTemplateInput!) { renderTemplate(input: $tpl) { output } }]], { tpl = { handle = "hp-indigo-jdf", context = ctx.json.encode({ jobId = input.jobId, copies = input.quantity, substrate = input.paper_type }) }})
local ticket = res.data.renderTemplate.outputoutput is the rendered text. You can also use the GraphQL workflow node to call
renderTemplate without writing Lua.
Shortcut: ctx.template.render
Section titled “Shortcut: ctx.template.render”Scripts and Custom Apps can skip the GraphQL round-trip with the direct Lua call. It takes the template handle and a JSON-encoded context string, and returns the rendered text:
local ticket = ctx.template.render("hp-indigo-jdf", ctx.json.encode({ jobId = input.jobId, copies = input.quantity, substrate = input.paper_type}))