aboutsummaryrefslogtreecommitdiff
path: root/doc/plugins/contrib/ftemplate.mdwn
blob: bcc6f2c67ecc7fd3f1396d83782a09783b525991 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
[[!template id=plugin name=ftemplate author="[[rubykat]]"]]
[[!tag type/meta type/format]]
[[!toc]]
## NAME

IkiWiki::Plugin::ftemplate - field-aware structured template plugin

## SYNOPSIS

    # activate the plugin
    add_plugins => [qw{goodstuff ftemplate ....}],

## DESCRIPTION

This plugin provides the **ftemplate** directive.  This is like
the [[ikiwiki/directive/template]] directive, with the addition that one does not
have to provide all the values in the call to the template,
because ftemplate can query structured data ("fields") using
the [[field]] plugin.

Templates are files that can be filled out and inserted into pages in
the wiki, by using the ftemplate directive. The directive has an id
parameter that identifies the template to use.

Additional parameters can be used to fill out the template, in
addition to the "field" values.  Passed-in values override the
"field" values.

There are two places where template files can live.  One is, as with the
[[plugins/template]] plugin, in the /templates directory on the wiki.  These
templates are wiki pages, and can be edited from the web like other wiki
pages.

The second place where template files can live is in the global
templates directory (the same place where the page.tmpl template lives).
This is a useful place to put template files if you want to prevent
them being edited from the web, and you don't want to have to make
them work as wiki pages.

### EXAMPLES

#### Example 1

PageA:

    [[!meta title="I Am Page A"]]
    [[!meta description="A is for Apple."]]
    [[!meta author="Fred Nurk"]]
    [[!ftemplate id="mytemplate"]]

Template "mytemplate":

    # <TMPL_VAR NAME="TITLE">
    by <TMPL_VAR NAME="AUTHOR">

    **Summary:** <TMPL_VAR NAME="DESCRIPTION">

This will give:

    <h1>I Am Page A</h1>
    <p>by Fred Nurk</p>
    <p><strong>Summary:</strong> A is for Apple.

#### Example 2: Overriding values

PageB:

    [[!meta title="I Am Page B"]]
    [[!meta description="B is for Banana."]]
    [[!meta author="Fred Nurk"]]
    [[!ftemplate id="mytemplate" title="Bananananananas"]]

This will give:

    <h1>Bananananananas</h1>
    <p>by Fred Nurk</p>
    <p><strong>Summary:</strong> B is for Banana.

### LIMITATIONS

One cannot query the values of fields on pages other than the current
page.

## PREREQUISITES

    IkiWiki
    IkiWiki::Plugin::field
    HTML::Template
    Encode

## DOWNLOAD

* browse at GitHub: <http://github.com/rubykat/ikiplugins/blob/master/IkiWiki/Plugin/ftemplate.pm>
* git repo at git://github.com/rubykat/ikiplugins.git