DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:templater

Templater Plugin

Compatible with DokuWiki

  • 2024-02-06 "Kaos" unknown
  • 2023-04-04 "Jack Jackrum" yes
  • 2022-07-31 "Igor" yes
  • 2020-07-29 "Hogfather" unknown

plugin Allows DokuWiki pages to be used as templates for insertion into other pages, similar to Wikipedia

Last updated on
2023-12-14
Provides
Syntax
Repository
Source

Description

Templater plugin is a fork of a very old version of include plugin. Like the include plugin, it allows you to embed one wikipage inside of another. Unlike the include plugin, the Templater also allows you to pass substitution strings to the wikipage to be included, changing the output of the included wikipage (as with MediaWiki's infobox).

Include from a… Code to insert
…whole single page {{template>pagename}}
…different namespace {{template>namespace:pagename}}
…top namespace {{template>:pagename}}
…subnamespace {{template>.namespace:pagename}}
…section (including all its subsections) [1] {{template>pagename#sectionname}}

[1]: When including only a specific section, the specified heading will not be printed, only the subheadings will be (lower level). And when the plugin finds a header at the same level as the specified heading, it stops printing.

Parameters and String Substitutions

The real power of Templater comes in to play when you want to use the same general layout for an element inside of a wikipage, but with different pieces of data. You create a new template page, and instead of putting in the actual values, you give each value a name, and enclose them in at-signs like this:

My name is @name@. I am a @value@.

Including in a wikipage and substituting strings:

{{template>pagename|name=Daniel|value=maintainer}}

Which outputs this:

My name is Daniel. I am a maintainer.

:!: Important notes:

  1. Users can enclose even titles and subtitles in between at-signs (@)! In other words: titles and subtitles can also be parameters to be provided in templates.
  2. Users can wrap their strings in quotation marks in order to keep any intentional leading or trailing whitespace. Useful for bulleted lists, code blocks etc. If you need the substituted string to end or begin with quotation marks, just use double quotes as in ""my string"".
  3. For now it's impossible to use image tags {{URL}} as direct values. You must add a parameter with {{ and }} outside the at-signs, as with {{@img@}}.

Escape Sequences

There are just one for now.

Character Escape sequence
| \|
= automatic, no action needed

Installation

To install, you can use the URL given above.

For more details, read plugin installation instructions.

Style

The included page is set into a <div> tag of class templater.

.templater {
    padding: 0.5em;
}

Recent Changes

To Do

  • Better error handling in _massageReplacers
  • Make templated (generated) pages indexable using idx_addPage() for fulltext search and backlink lookup using ft_backlinks()
  • Template caching of parser instructions.
  • Make the code a little clearer
  • Use > in template arguments to point to a wikipage containing a dataset.
  • Default template namespace. → added only config entry, but not implemented

FAQ

Is there any way to include MediaWiki's ParserFunctions in a template?

About MediaWiki's ParserFunctions. Take a look at ParserFunctions plugin.

Is generated content indexable?

No, but this is in the roadmap. Pages should be indexable by using idx_addPage(), and for for fulltext search and backlink lookup using ft_backlinks().

Is possible to include pictures in the page using a template?

Yes, but it depends on how you do it.

You can not directly include the image tag inside a template: {{<url>}}. Instead, you sould use a parameter with key brackets around it: {{@<url>@}}, then provide only the URL as a parameter.

Is possible to use template inline?

No, and i don't know how to implement that.

File syntax.php renders page around lines 220-240. But delete <div>s changes nothing. Some issue with DokuWiki's p_render. XHTML always render any text in a line as <p>…</p> and it's always breaks line.

Compatibility with ODT plugin

Pages exported with ODT plugin are empty and I don't know how to fix it.

Compatibility with other DokuWiki templates

This plugin was tested only with DokuWiki default template, other templates was not (and will not be) tested. At least one user reported that this plugin does not work as expected with dokucms.


Discussion

House cleaning
Outgrown discussions about bugs and new features that have already been fixed or included in past versions will be deleted.
Discussions stopped for a long time will be deleted and included in the FAQ.

Data entry and handling suggestions.

I very much needed this plugin, thanks. I think the data entry needs to be handled much easier than it currently is. Maybe something similar to the template plugin datafiles which uses a normal DokuWiki list of name:value pairs and is much easier to write. The template plugin allows the data to be culled from a data page or inline in the arguments. Also the template plugin data files support multiple records in one file, if would be very nice to see a module mode where it can loop the data set through the template for each one or for a specific field match. Oh that would also allow for entry of more markup that cant be normally added in {}.

— ShawnA


Footnotes

Currently, footnotes are rendered at the end of the template rather than the end of the page. For some use cases this is fine, but for things like infoboxes, it breaks the entire formatting of the page, with only moderate workarounds available.

Thanks for adopting this plugin!

Turq Whiteside

This comportament of footnotes was true for me up to this afternoon, but this night it's working… I don't understand. I have changed rewrite rules as explained in rewrite, setting to .htaccess. But even getting back to normal (userwrite = 0), it's still working.
Daniel D. Rodrigues 2023-12-06 02:05
plugin/templater.txt · Last modified: 2024-02-26 13:30 by nerun

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki