Remember that for each page tracked by Nift there is a specified template path. When building a page, Nift will start processing the template file the same as it will process any other file. Consequently everything that applied to writing content files also applies to writing template files. However, unlike content files, template files (or one of their dependencies) need to use the page content file as a page dependency.
Specifying where content is to be inputted
Nift treats any instance of @inputcontent as being equivalent to @input(path-to-content), where path-to-content is the content path for a page.
Note: if @inputcontent is in any dependency of a page's content file (content file inclusive), then an input loop would be formed when attempting to build the page so Nift will (at least it should) throw an error. You may however put @inputcontent in any other dependencies of the template file. For example were your template to include a file template/body.template, it is fine for @inputcontent to reside in body.template and not the main template file.
Alternatively to @inputcontent you can:
- use @inputraw which will input the content file without parsing it with Nift's template language
- use @systemcontent(sys-call) which is equivalent to @systemcontent*(sys-call @contentpath), where @contentpath injects the content path for a page. For example if your content files are markdown and you use @systemoutput("pandoc") then the content files will be injected after being converted to html using pandoc
- use @scriptoutput*(@contentpath)
- use @dep*(@contentpath)
Optionally injecting head content
You can optionally add @inputhead which will input page-name.head if the file exists. So if you want to optionally add code for a page at that point add a file page-name.head in the same directory as the page content file. This is very similar to doing @input*(@email@example.com) except the existence of the file is optional.
Specifying where the page title is to be inputted
When building a page, Nift will replace any instance of @pagetitle with the title Nift has tracked for the page. Unlike @inputcontent, @pagetitle may be placed inside content files (template files inclusive).
Example template files
A very simple template file, that specifies both where content and the page title are to be inputted, would be:
<title>site title - @pagetitle</title>
It can be convenient to break what would typically be found inside the template file up into various content files. For example you may have template/head.content, template/menu.content and template/footer.content. A suitable template file, say the default template/page.template would then be:
Note: the head tags may be put inside either template/page.template or template/head.content. However if the head tags are left inside template/page.template then, rather than specifically having to alter template/head.content, the head may be altered from both template/page.template and template/head.content.