Replace a document template's draft
Replaces the draft. Published revisions and what is published are unchanged until the next publish.
Request
- Base URL: https://api.ironfang.com/render
- URL: https://api.ironfang.com/render/v1/document-templates/{id}
- Auth: HTTP bearer
Request body
Data for previews and validation when a request gives none. Keep it synthetic.
The data the template needs, as a strict subset of JSON Schema: type (object, array, string, number, integer, boolean), properties, required, items, maxItems, maxLength, enum, nullable, default and description; any other keyword is refused. The top level is an object. Data is checked against it before anything renders. A required field is never defaulted; an optional one missing from the data gets its default, or null, so {{if .notes}} is a test rather than an error. Fields declared integer are whole numbers, so {{if gt .days 30}} works.
HTML in Go's html/template syntax: {{.customer.name}}, {{range .lines}}...{{end}}, {{if .notes}}...{{end}}. Values are escaped for where they land - text, attributes, URLs (a javascript: URL becomes #ZgotmplZ), CSS and scripts. Functions: the html/template builtins (and, or, not, eq, ne, lt, le, gt, ge, len, index, slice), fixed N value (a number to N decimal places), mul, add, upper, lower and printf (widths at most 64). {{define}}, {{template}} and {{block}} are not supported. A field the template reads that the data lacks is an error, never an empty string: declare optional fields in the schema. Rendering is bounded: 100,000 loop iterations, 8 MiB of HTML and 2 s. Saving refuses a source that does not compile.
Response
Updated.
Data for previews and validation when a request gives none. Keep it synthetic.
The data the template needs, as a strict subset of JSON Schema: type (object, array, string, number, integer, boolean), properties, required, items, maxItems, maxLength, enum, nullable, default and description; any other keyword is refused. The top level is an object. Data is checked against it before anything renders. A required field is never defaulted; an optional one missing from the data gets its default, or null, so {{if .notes}} is a test rather than an error. Fields declared integer are whole numbers, so {{if gt .days 30}} works.
HTML in Go's html/template syntax: {{.customer.name}}, {{range .lines}}...{{end}}, {{if .notes}}...{{end}}. Values are escaped for where they land - text, attributes, URLs (a javascript: URL becomes #ZgotmplZ), CSS and scripts. Functions: the html/template builtins (and, or, not, eq, ne, lt, le, gt, ge, len, index, slice), fixed N value (a number to N decimal places), mul, add, upper, lower and printf (widths at most 64). {{define}}, {{template}} and {{block}} are not supported. A field the template reads that the data lacks is an error, never an empty string: declare optional fields in the schema. Rendering is bounded: 100,000 loop iterations, 8 MiB of HTML and 2 s. Saving refuses a source that does not compile.
Set once archived. Archived templates render only by revision number.
The revision unversioned renders use; null until first published.
Changes
No recorded changes to this operation across all 1 revision of this API.