From 7672014582a994624503399a1f50e855c4fc9ca7 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 21 Feb 2014 22:45:29 +0000 Subject: Add templatebody plugin and directive, and enable it by default Also add a regression test for templatebody. --- doc/ikiwiki/directive/edittemplate.mdwn | 12 ++++++++++-- doc/ikiwiki/directive/template.mdwn | 20 +++++++++++++++++--- doc/ikiwiki/directive/templatebody.mdwn | 28 ++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 doc/ikiwiki/directive/templatebody.mdwn (limited to 'doc/ikiwiki') diff --git a/doc/ikiwiki/directive/edittemplate.mdwn b/doc/ikiwiki/directive/edittemplate.mdwn index a6f301dd3..b3177daa8 100644 --- a/doc/ikiwiki/directive/edittemplate.mdwn +++ b/doc/ikiwiki/directive/edittemplate.mdwn @@ -18,17 +18,25 @@ the directive displaying a note about the template being registered, add "silent=yes". Often the template page contains a simple skeleton for a particular type of -page. For the bug report pages in the above example, it might look -something like: +page, wrapped in a [[templatebody]] directive. For the bug report pages in +the above example, it might look something like: + \[[!templatebody <` is replaced with the name of the page being created. +Text outside the [[templatebody]] directive is not part of the template, +and can be used to document it. + +If the template does not contain a [[templatebody]] directive, the entire +source of the page is used for the template. This is deprecated. + [[!meta robots="noindex, follow"]] diff --git a/doc/ikiwiki/directive/template.mdwn b/doc/ikiwiki/directive/template.mdwn index 9e3ae54df..dd1ca3d52 100644 --- a/doc/ikiwiki/directive/template.mdwn +++ b/doc/ikiwiki/directive/template.mdwn @@ -31,16 +31,25 @@ large chunks of marked up text to be embedded into a template: ## Creating a template -The template is a regular wiki page, located in the `templates/` +The template is in a regular wiki page, located in the `templates/` subdirectory inside the source directory of the wiki. +The contents of the [[templatebody]] directive are used as the +template. Anything outside that directive is not included in the template, +and is usually used as documentation describing the template. + +If the template does not contain a [[templatebody]] directive, the entire +source of the page is used for the template. This is deprecated, because +it leads to the template markup being interpreted as ordinary +page source when the page is built, as well as being used as the template. Alternatively, templates can be stored in a directory outside the wiki, as files with the extension ".tmpl". By default, these are searched for in `/usr/share/ikiwiki/templates`, the `templatedir` setting can be used to make another directory be searched first. When referring to templates outside the wiki source directory, the "id" -parameter is not interpreted as a pagespec, and you must include the full filename -of the template page, including the ".tmpl" extension. E.g.: +parameter is not interpreted as a pagespec, you must include the full filename +of the template page including the ".tmpl" extension, +and the templatebody directive is not used. E.g.: \[[!template id=blogpost.tmpl]] @@ -63,6 +72,7 @@ few things: Here's a sample template: + \[[!templatebody < Name: \[[]]
Age:
@@ -76,6 +86,10 @@ Here's a sample template: + ENDBODY]] + + This template describes a person. Parameters: name, age, + color (favorite color, optional), notes (optional). The filled out template will be formatted the same as the rest of the page that contains it, so you can include WikiLinks and all other forms of wiki diff --git a/doc/ikiwiki/directive/templatebody.mdwn b/doc/ikiwiki/directive/templatebody.mdwn new file mode 100644 index 000000000..dfadb2c2d --- /dev/null +++ b/doc/ikiwiki/directive/templatebody.mdwn @@ -0,0 +1,28 @@ +The `templatebody` directive is supplied by the +[[!iki plugins/templatebody desc=templatebody]] plugin. + +This directive allows wiki pages to be used as templates +for the [[template]] or [[edittemplate]] directive, without having +[[!cpan HTML::Template]] markup interpreted as wiki markup when that +page is built. + +This directive does not produce any output in the wiki page that +defines the template; the rest of that page can be used to to document +how to use the template. + +The first, un-named parameter is the content of the template. +Because templates often contain [[directives|ikiwiki/directive]], it's +convenient to use the "here-document" syntax for it: + + \[[!templatebody < +
Name:
+
Age:
+ + + + ENDBODY]] + +[[!meta robots="noindex, follow"]] -- cgit v1.2.3