Page Includes
The Page Metadata syntax is also used for including pages into other pages.
Basic Include Syntax
For instance, to include the Warning
page in another page:
{{include: Warning}}
You can supply a relative or absolute page name to the include
meta --
Linking resolving rules apply. For convenience, however, if the path is
not absolute, Wikked will first look in the /Templates
folder for a page of
that name to include. If it doesn't find one, it will resolve the path as usual.
You can make Wikked look into a different folder than
/Templates
by changing thetemplates_dir
option in the configuration file. See Configuration.
Templated Include
The include
metadata accepts arguments. For example, the City of Oz
page may have this at the top:
{{include: Warning
|a work in progress
|adding references
}}
Those arguments can then be used by the included /Templates/Warning
page:
WARNING! This page is {{__args[0]}}.
You can help by {{__args[1]}}.
This will make City of Oz
print the following warning:
WARNING! This page is a work in progress.
You can help by adding references.
As you can see, arguments are passed as an array named __args
, and this can be
inserted using double curly brackets. So {{__args[0]}}
inserts the first passed argument, {{__args[1]}}
inserts the
second, and so on.
You can also pass arguments by name:
{{include: Presentation
|what=dog
|nickname=Toto
}}
And use them by name in the included /Templates/Presentation
template:
This page is about a {{what}} named "{{nickname}}".
In reality, when included, a page's text will be processed through Jinja2
templating so you can also use all kinds of fancy logic. For example, if you
want to support a default warning message, and an optional information message,
you can rewrite the /Template/Warning
page like so:
WARNING! This page is {{__args[0]|default('not ready')}}.
{%if __args[1]%}You can help by {{__args[1]}}.{%endif%}
For more information about what you can do, refer to the Jinja2 templating documentation.
Included Metadata
Pages with other pages included in them inherit the meta properties of the
included pages. So if /Templates/Presentation
has {{category:
Characters}}
, then a page including it will also be in the
"Characters" category.
You can tweak that behaviour:
-
Meta properties that start with
__
(double underscore) will be "local" or "private" to that page, i.e. they won't be inherited by including pages. -
Meta properties that start with
+
(plus sign) will only be "added" or "given" to includnig pages, i.e. the current page won't have that property, but pages including it will.