1 [[!template id=plugin name=ymlfront author="[[rubykat]]"]]
6 IkiWiki::Plugin::ymlfront - add YAML-format data to a page
11 add_plugins => [qw{goodstuff ymlfront ....}],
13 # configure the plugin
14 ymlfront_delim => [qw(--YAML-- --YAML--)],
18 This plugin provides a way of adding arbitrary meta-data (data fields) to any
19 page by prefixing the page with a YAML-format document. This also provides
20 the [[ikiwiki/directive/ymlfront]] directive, which enables one to put
21 YAML-formatted data inside a standard IkiWiki [[ikiwiki/directive]].
23 This is a way to create per-page structured data, where each page is
24 treated like a record, and the structured data are fields in that record. This
25 can include the meta-data for that page, such as the page title.
27 This plugin is meant to be used in conjunction with the [[field]] plugin.
31 There are three formats for adding YAML data to a page. These formats
32 should not be mixed - the result is undefined.
36 See [[ikiwiki/directive/ymlfront]] for more information.
38 2. default YAML-compatible delimiter
40 By default, the YAML-format data in a page is placed at the start of
41 the page and delimited by lines containing precisely three dashes.
42 This is what YAML itself uses to delimit multiple documents.
43 The "normal" content of the page then follows.
48 title: Foo does not work
54 When running on the Sprongle system, the Foo function returns incorrect data.
56 What will normally be displayed is everything following the second line of dashes. That will be htmlized using the page-type of the page-file.
58 3. user-defined delimiter
60 Instead of using the default "---" delimiter, the user can define,
61 in the configuration file, the **ymlfront_delim** value, which is an
62 array containing two strings. The first string defines the markup for
63 the start of the YAML data, and the second string defines the markip
64 for the end of the YAML data. These two strings can be the same, or
65 they can be different. In this case, the YAML data section is not
66 required to be at the start of the page, but as with the default, it
67 is expected that only one data section will be on the page.
72 title: Foo does not work
78 When running on the Sprongle system, the Foo function returns incorrect data.
80 What will normally be displayed is everything outside the delimiters,
81 both before and after. That will be htmlized using the page-type of the page-file.
83 ### Accessing the Data
85 There are a few ways to access the given YAML data.
89 The **getfield** plugin can display the data as individual variable values.
94 title: Foo does not work
102 **Urgency:** {{$Urgency}}\\
103 **Status:** {{$Status}}\\
104 **Assigned To:** {{$AssignedTo}}\\
105 **Version:** {{$Version}}
107 When running on the Sprongle system, the Foo function returns incorrect data.
109 * [[ftemplate]] plugin
111 The **ftemplate** plugin is like the [[plugins/template]] plugin, but it is also aware of [[field]] values.
116 title: Foo does not work
119 AssignedTo: Fred Nurk
122 \[[!ftemplate id="bug_display_template"]]
124 When running on the Sprongle system, the Foo function returns incorrect data.
128 The **report** plugin is like the [[ftemplate]] plugin, but it reports on multiple pages, rather than just the current page.
130 * write your own plugin
132 In conjunction with the [[field]] plugin, you can write your own plugin to access the data.
137 IkiWiki::Plugin::field
142 * browse at GitHub: <http://github.com/rubykat/ikiplugins/blob/master/IkiWiki/Plugin/ymlfront.pm>
143 * git repo at git://github.com/rubykat/ikiplugins.git