ikiwiki/doc/todo/else_parameter_for_map_plug...

48 lines
1.9 KiB
Plaintext
Raw Normal View History

[[!tag patch]]
[[plugins/map]] (and I) could benefit from a bonus parameter:
else="Display this if no page matches the PageSpec"
This was quite simple, so I implemented this (branch "map" in my
ikiwiki repo, see my user page for the up-to-date URL). Not patched the
documentation yet, I'm waiting for feedback first, but I'll do it for sure. -- [[intrigeri]]
2008-07-16 23:58:36 +02:00
> Can't a [[plugins/conditional]] be for this?
> --[[Joey]]
2008-07-18 01:31:32 +02:00
>> Hmmm, what do you mean? Adding a syntax such as the one below?
>> Or something else?
\[[!if test="map(" then="..." else="..."]]
2008-07-18 01:31:32 +02:00
>> What would you write in the `then` clause?
>> I'm not opposed at all to rewrite my two-liner, but I don't understand.
>> --[[intrigeri]]
2008-07-18 01:35:43 +02:00
\[[!if test="foo/*" then="""
[[!map pages="foo/*"]]
2008-07-18 01:36:28 +02:00
""" else="no pages"]]
2008-07-18 01:35:43 +02:00
--[[Joey]]
2008-07-18 12:22:51 +02:00
>>> I'm not convinced: the syntax you're proposing implies to duplicate
>>> the pagespec (once in the test clause, and once in the map query), which I find
>>> not only inelegant, which I can live with, but also tiring and unpractical:
>>> my `else` suggestion
>>> finds its roots in map queries with rather long pagespecs. On the other
>>> hand, if I'm the only one using map in such a way, I can live with this
>>> heavy duplicated syntax without bloating the map plugin with features
>>> no-one but me needs. On the other other hand, the patch is a 3-liner.
>>> I'm not fixed yet, I'll think about it. --[[intrigeri]]
2008-07-19 18:43:10 +02:00
>>>> Write a [[plugins/template]] which accepts a pagespec and an
>>>> "else" clause, and then you won't have to duplicate the
>>>> pagespec. --[[JoshTriplett]]
2008-07-19 19:17:36 +02:00
>>>> Yeah, the patch is obviously very simple. My problem with it really is
>>>> that there would seem to be several other places in ikiwiki where
>>>> someone might want to be able to handle an "else" case where a
>>>> pagespec expands to nothing. And adding else cases for all of them
>>>> could be a bit much. --[[Joey]]