Content-Type: text/x-zim-wiki
Wiki-Format: zim 0.4

====== Templates ======

Zim uses templates when exporting pages. This way you can for example write your website in zim and export it to HTML using the layout and style definition of you choice.

Templates are also used to initalize new pages.

===== Templates for export =====

For a list of templates for exporting see [[Help:Export]] and subpages. 

===== Template options =====

Templates can also set template options that influence the generated output, by setting key-value pairs like in the example below. A list of available template options for a output format can be found at [[Help:Export]] and subpages.

===== Special templates =====

**"_New"**
This template is used to initialize new pages. The default contains a header with the page name and a the date at which the page was created.

===== Customizing =====

Templates are located in ''/usr/share/zim/templates/'' and ''~/.local/share/zim/templates'' by default. You can add templates you use more often there. To modify a template copy it to the ''~/.local/...'' directory and edit it.

Template syntax:



'''
[% var %]                   # interpolates a variable

[% IF var %] ... [% END %]  # conditionals

[% IF var %]
	...
[% ELSE %]
	...
[% END %]

[% FOREACH name = var ]     # loop
... [% name %] ...
[% END %]

[% strftime("%c") %]		# current time stamp
[% strftime("%c", var) %]   # date from variable
'''


'''
[% options.option_name = value %] # set the template option option_name to value
'''

Available variables:

'''
page.name		# complete page name
page.namespace		# namespace
page.title		# last part of the name of the page
page.heading		# title or first heading in the page
page.body		# content of the page
page.links		# list of vars with a .file and a .name subvar
page.backlinks		# "" idem ""
page.is_index		# true for the automatic generated index page
prev.name		# name of previous page
prev.file		# file name of previous page
next.name		# name of next page
next.file		# file name of next page
notebook.root		# root dir relative to page file
zim.version		# version of zim
'''

The "Title" field contains either the first heading in the page or the page name. If the first header is used, this header is removed from the "Body" field.
