Let's look at some of the things that a good header template will want to have:
- The name of the book, which will probably double as a hyperlink to the TOC
- "Next" and "Back" links, for easy navigation
- Categories. The template should put all pages where it is transcluded into a category for all pages in the book.
- Some documentation, to explain to users how to use the template.
<includeonly><no</includeonly>include>[[Category:Exclude in print]]</includeonly></no<includeonly>include></includeonly>
This is quite a mess! But that's the purpose of the meta template, I write this mess once and nobody else ever has to do it again. When we substitute the meta template to create a new navigation template, we get this:
<noinclude>[[Category:Exclude in print]]</noinclude>
So that makes more sense to see the result. We have to do all the mess above because if we didn't break up the
noinclude
tags in the meta template, they would disappear when we substituted into the navigation template.Let's look at the related, but more complicated, problem of having next and back links that appear only when values are provided. Here's the code that I have to use in the meta-template:
<includeonly>{{</includeonly>#if: {{{last|}}} | ← [[{{{book}}}/{{{last}}}|{{{last}}}]] | }}
Again, without the
includeonly
tags put in those weird places, the {{#if:}}
tag would disappear when we substituted. Now when we substitute, the includeonly
tags disappear, leaving a perfectly-formed tag in their place:
{{#if: {{{last|}}} | ← [[{{{book}}}/{{{last}}}|{{{last}}}]] | }}
This string of stuff isn't exactly clean and isn't easy to read either, but at least the new users don't have to write it themselves. Anything we can do to decrease the barrier to entry for aspiring new book authors is always a good thing.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.