UserGuide: Writing templates

LionWiki contains very simple templating mechanism which can be used to significantly alter visual look of your wiki site.

Template is ordinary file, usually named something like template_name.html. As you can see from file extension, it's HTML file and can be displayed by browser.

Besides ordinary HTML tags, it's filled with some strings enclosed by { and }:


I'll call them template tags.

So, LionWiki generates the page (doesn't print it yet) and read the template file. It finds all these template tags and tries to substitute them. Then, prints the page (i.e. sends it to the browser).

There's one catch - we have a lot of different pages (recent changes, revision list, etc.) but just one template. This means that these different pages can't look very different - they all come from one template. But it's generally good to have consistent design across your site.

But there's another problem - not all template tags (e.g. {EDIT} for edit button) have meaning on all pages (in this case in Recent changes, History ...). We resolve this by substituting unmeaningful template tags with nothing - in mentioned case edit link is just not displayed.

Let's imagine a situation in which we want to create navigation bulleted list:


Home tag is relevant on all pages of the site, edit link is not, it doesn't make sense on e.g. recent changes page. So, what happens if we are on recent changes?

* LionWiki

We get empty bullet, which is actually not very pretty.

LionWiki has therefore special syntax for this case:

	{<li> EDIT </li>}

In this case, we get:

* LionWiki

What does this syntax mean? If EDIT tag is relevant for current page, it prints <li>EDIT</li>, but if it's not, it prints nothing. This syntax means that everything between { and } is actually part of the template tag. In short, either everything is printed or nothing.

It's important to note that there must be at least one space on both sides of template tag, i.e. {<li> EDIT </li>} is correct but {<li>EDIT</li>} is not. These surrounding spaces are not inserted into printed page, it's sole purpose is to be delimiter. If you want space there, you can add another one and this one will be printed.

List of all template tags(Edit)

I'm not gonna write one. You can take a look at Red template which demonstrates use of almost all of them.