A method for quickly adding export templates follows that for built-in Prototypes. A File menu item displays a sub-menu of built-in export templates that can be added to the current document.
If no export templates already exist, a root-level container 'Templates' is added. The 'Templates' container's $OnAdd is set to $IsTemplate = true;
. Also the built-in prototype 'HTML' ('HTML Template' in older versions) is added to the existing built-in Prototypes container or the latter container is also added. If a 'Templates' and/or 'Prototypes' container exists these are used for any newly added notes instead of creating new containers.
From v8, the built-in Templates container is required to be a top-level note; an interior note names "templates" or "Templates" will not be adopted as the document's built-in templates container.
When a document is loaded, Tinderbox checks all notes that are used as (a) an HTMLExportTemplate, (b) an EmailTemplate, or (c) a PosterTemplate. If a note is in use as a template, it is marked so $IsTemplate is true. Notes that are not currently in use as templates are not marked with $IsTemplate as false; a note my advertise its willingness to serve as a template even if it is not in use.
The offered built-in templates are:
- HTML. HTML5 page export, with includes for all descendants. This inserts two templates in the form of a wrapper template, which is applied to the main note to export and which then recursively calls a per-item template to include all the main page's descendants. The item template is inserted as a child of the wrapper, emphasising the usage. To export only the current note's content use the new HTML Single note template.
- HTML Single note. HTML5 page export, but exports only the current note.
- OPML. OPML export, with includes. This inserts two templates in the form of a wrapper template which is applied to the main note to export and which then recursively calls a per-item template to include all the main page's descendants. The item template is inserted as a child of the wrapper, emphasising the usage.
- Scrivener. OPML export, with includes. This is actually the same code as for OPML, but offered to aid non-technical Scrivener users and to allow easy branching for any possible Scrivener-only variations.
- Preview. This is the template auto-inserted for zero-configuration internal preview, but can be imported from the Templates menu as it may be desirable to configure the template before use. This replaces the 'preview' note in /Hints. This is the default template for Markdown notes. The template automatically includes the CSS styles defined in the Preview style note. The Preview template can be customised to add headers, footers, or other elements for more structured internal preview use.
Once templates are added the user can modify the template code.
In addition to the above, the users own selection of templates stored in the application support 'templates' folder are also available.
Note that a prototype that is also an export template (e.g. 'HTML Template', below) will not be listed in the Template pop-up menu. This is so that a note can inherit template status via a template without cluttering the template listing with prototypes.
See also—notes linking to here: