]> sipb.mit.edu Git - ikiwiki.git/blob - doc/todo/shortcut_optional_parameters.mdwn
web commit by cworth
[ikiwiki.git] / doc / todo / shortcut_optional_parameters.mdwn
1 Consider the "All files in this package search" on
2 <http://packages.debian.org>.  The URL for such a search looks like this:
3
4     http://packages.debian.org/cgi-bin/search_contents.pl?word=packagename&searchmode=filelist&case=insensitive&version=unstable&arch=i386
5
6 To create a "debfiles" [[shortcut|shortcuts]] that takes a package name, you
7 could just hardcode the architecture and distribution:
8
9     \[[shortcut name=debfiles url="http://packages.debian.org/cgi-bin/search_contents.pl?word=%s&searchmode=filelist&case=insensitive&version=unstable&arch=i386"]]
10     \[[debfiles ikiwiki]]
11
12 But what if you could have them as optional parameters instead?  The syntax
13 for the invocation should look like this:
14
15     \[[debfiles ikiwiki dist=testing]]
16
17 Some possible syntax choices for the shortcut definition:
18
19     \[[shortcut name=debfiles url="http://packages.debian.org/cgi-bin/search_contents.pl?word=%s&searchmode=filelist&case=insensitive&version=%(dist)s&arch=%(arch)s" dist="unstable" arch="i386"]]
20     \[[shortcut name=debfiles url="http://packages.debian.org/cgi-bin/search_contents.pl?word=%s&searchmode=filelist&case=insensitive&version=%(dist=unstable)s&arch=%(arch=i386)s"]]
21     \[[shortcut name=debfiles url="http://packages.debian.org/cgi-bin/search_contents.pl?word=%s&searchmode=filelist&case=insensitive&version=%{dist=unstable}&arch=%{arch=i386}"]]
22     \[[shortcut name=debfiles url="http://packages.debian.org/cgi-bin/search_contents.pl?word=$*&searchmode=filelist&case=insensitive&version=${dist=unstable}&arch=${arch=i386}"]]
23
24 --[[JoshTriplett]]
25
26 Well, you can already do this kind of thing with templates. Invocation does
27 look different:
28
29     \[[template id=debfiles package=ikiwiki dist=testing]]
30
31 --[[Joey]]
32
33 > I think I would find templates sufficient, if:
34 >
35 > 1. I could use the name of the template as a preprocessor directive
36 >    (`\[[templatename ...]]`), rather than using the `template` directive
37 >    with an `id` argument (`\[[template id=templatename]]`).
38 > 2. Template invocation allowed bare values in addition to `key=value`
39 >    arguments, and template definition supported some means to access the
40 >    value.  This would allow `\[[debfiles ikiwiki]]` rather than
41 >    `\[[debfiles package=ikiwiki]]`.
42 > 3. I could use ikiwiki syntax in the template, not just HTML and
43 >    HTML::Template.  (If I can already do that, then [[/plugins/template]]
44 >    should make that more clear.)
45 >
46 > --[[JoshTriplett]]