Filter operators: inverting input and parameters

One thing I realized that you can’t have a variable containing the name of a variable containing a filter name. What I mean is this:

<$vars asterix="[addsuffix[*]]" obelix="[addprefix[(menhir)-]]" warrior="Astérix">
<$set name=draw filter="[<warrior>match[Astérix]then[asterix]else[obelix]]">
<$set name=drawing select=0 filter="[<warrior>subfilter<draw>]">
<<drawing>>
</$set></$set></$vars>

The result is “asterix” when I wish it to be “Astérix*”.

This example is totally dumb but it was as simple as I could do it and yet show you what ca not be done yet. The possibility would help expand coding with filter names without having to add macros just for tge sake of an if or without having to distort your filter code. It would be an other possibility that some would use and some would not.

(in that dumb example, you could do the output in a more legible and more concise manner. This is not the real life code where I wrote code that required this not yet existing possibility. A complex set of code where I have to nest map inside map inside map!)

<$vars asterix="[addsuffix[*]]" obelix="[addprefix[(menhir)-]]" warrior="Astérix">
<$set name=draw filter="[<warrior>match[Astérix]then[asterix]else[obelix]]">
<$set name=drawing select=0 filter="[<warrior>subfilter<draw>]">
<<drawing>>
</$set></$set></$vars>

The result is “asterix” when I wish it to be “Astérix*”.

In order to get the results you want in the example code above, instead of:

<$set name=draw filter="[<warrior>match[Astérix]then[asterix]else[obelix]]">

you want to write

<$set name=draw filter="[<warrior>match[Astérix]then<asterix>else<obelix>]">

This will assign the desired filter expression as literal text in the draw variable. The filter expression is subsequently evaluated by subfilter<draw>

Also, you should note that “macros” ARE “variables”… just with the added ability to perform text substitution of parameters passed to them.

-e

TShanks, @EricShulman. I wanted the name of the filter as a value of draw as it is easier to check, easier to test, too. I’m afraid I currently can’t.