]> sipb.mit.edu Git - ikiwiki.git/blob - doc/ikiwiki/directive/cutpaste.mdwn
listdirectives: Enable use of the directives underlay.
[ikiwiki.git] / doc / ikiwiki / directive / cutpaste.mdwn
1 The `copy`, `cut` and `paste` directives are supplied by the
2 [[!iki plugins/cutpaste]] plugin.
3
4 With these directives you can store and recall pieces of text in a page:
5
6  * `\[[!cut id=name text="text"]]` memorizes the text allowing to recall it
7    using the given ID.  The text being cut is not included in the output.
8  * `\[[!copy id=name text="text"]]` memorizes the text allowing to recall it
9    using the given ID.  The text being cut *is* included in the output.
10  * `\[[!paste id=name]]` is replaced by the previously memorized text.
11
12 The text being cut, copied and pasted can freely include wiki markup, including
13 more calls to cut, copy and paste.
14
15 You do not need to memorize the text before using it: a cut directive can
16 follow the paste directive that uses its text.  In fact, this is quite useful
17 to postpone big blocks of text like long annotations and have a more natural
18 flow.  For example:
19
20         This plugin provides three directives:
21
22          * \[[!toggle id="cut" text="cut"]] that cuts text
23          * \[[!toggle id="copy" text="copy"]] that copies text
24          * \[[!toggle id="paste" text="paste"]] that pastes text
25
26         \[[!toggleable id="cut" text="\[[!paste id=cutlongdesc]]"]]
27         \[[!toggleable id="copy" text="\[[!paste id=copylongdesc]]"]]
28         \[[!toggleable id="paste" text="\[[!paste id=pastelongdesc]]"]]
29
30         \[...some time later...]
31
32         \[[!cut id=cutlongdesc text="""
33            blah blah blah
34         """]]
35         \[[!cut id=copylongdesc text="""
36            blah blah blah
37         """]]
38         \[[!cut id=pastelongdesc text="""
39            blah blah blah
40         """]]
41
42 This can potentially be used to create loops, but ikiwiki is clever and breaks
43 them.
44
45 Since you can paste without using double quotes, copy and paste can be used to
46 nest directives that require multiline parameters inside each other:
47
48         \[[!toggleable id=foo text="""
49           \[[!toggleable id=bar text="\[[!paste id=baz]]"]]
50         """]]
51
52         \[[!cut id=baz text="""
53         multiline parameter!
54         """]]
55
56 [[!meta robots="noindex, follow"]]