To use a template, start by adding ",new" after almost any URL on our site to see the templates available at that point of the site. ",new" is one of the comma-tools.
The text below explains how to create templates.
The templating system helps you create uniform documents for W3C pages, or helps you to prepare documents for particular circumstances (Last Call, etc).
New templates must be created in a directory which is called Templates
.
It is recommended to add a very short description of the template in a meta tag at the top of the document, e.g.:
<meta name="description" content="Press release">
The ,new tool will otherwise display the title of the document, but often the title is just "%%title%%".
When the template is called, a form will be created and displayed with the value of variable-name to input. We suggest that you choose a variable name which has a meaning. Spaces are allowed, but no colons (:) or equals signs (=). For example:
%%Your email address%%
The form will contain an entry with "Your email address" and an input field.
Same as above, but the form will show an input field pre-filled with the given default value.
This is for the rare case of variables that are inserted into a URL. E.g., if the template contains:
... <a href="http://example.org/process?name=%%name%%">process it...
and the variable "name" happens to contain certain characters such as "&", "=" or "/", the link will be incorrect. Instead, write it like this:
... <a href="http://example.org/process?name=%%url-escape:name">process it...
Don't use it where the variable constitutes the whole of
the URL, such as in <a href="%%url%%">
Technically, the prefix "url-escape" instructs the templating system to use so-called "%-escapes".
Instead of an input field for text, the form will contain a menu with the given options.
Do not put spaces after the colon (:) or after the commas (,), unless you want an actual space in the value.
Same as above, but the option that is equal to the default is already selected (instead of the first option). E.g.,
... %%color:red,green,blue,purple=blue%%...
will show a menu that looks like this:
URL-escaping, menus and defaults can be combined. E.g., here is a variable that has a menu of options, with a default option, and that will be URL-escaped in the generated document:
... %%url-escape: fraction:1/2,1/3,1/4,1/5=1/3%%..
When the variable is exactly yyyy, the form will show an input field prefilled with the current year. For example, "1969"
The form will show an input field prefilled with the month as two digits. For example, "02" for February
The form wil show an input field prefilled with the month in a 3-letter format. For example, "Feb" for February
The form will show an input field prefilled with the date. For example, "16"
It is possible to make conditional sections in a template. The part after %%if:variable-name%% will only be copied to the output if variable-name is defined (has a non-empty value). Otherwise, if there is an %%else%%, the part after %%else%% will be copied.
Somes examples of templates.