hi all,
i have a question about how transcluding an empty field. i am making a macro that needs to give the same result in these two cases:
the parameter is empty (like <<mymacro>>)
the parameter transcludes a field which is empty (like <<mymacro {{!!blankField}}>>).
#1 is easy ([<param>else[result]]), and something like [{!!blankfield}is[blank]then[result]] would work for #2, but i need to transclude the field (as opposed to passing its name to the macro as a parameter) so what should i do?
i guess my root question is: how do i use a filter to match the value given by a transcluded empty field?
I may be wrong because I am not sure of your question, but why not as follows;
[{!!blankfield}else[result]] or if it returns blanks, [{!!blankfield}!is[blank]else[result]]
However I tend to use filter in the list widget and rather than set “result”, I tend to make use of the fact if empty the content of the list widget is not displayed;
i would like either of these to set the language to en: <<myproc term>> <<myproc term {{!!blankField}}>>
and either of these to set the language to es: <<myproc term anyTextHere>> <<myproc term {{!!nonBlankField}}>>
despite {{!!blankField}} always transcluding to an empty string, <<flag>> never matches match[] or is[blank] when it is set to {{!!blankField}}… maybe this is due to the way procedures vs. macros interpret transclusions?
this works, thank you!
but i don’t understand why your solution does anything different than the OP, why does it matter if the filter is evaluated in the <$let> versus in the main filter?
just trying to understand so i can come to similar solutions in the future if needed.
also thanks @tw-FRed also for the help with the procedure call!
If you let the macro/procedure print the “flag” parameter using your original code, you’ll see that you just get plain-text substitution
The filter only sees the literal text {{!!blankField}} as the value for “flag” which makes the flag value not blank.
Using the $let widget is the easiest way I know of to get an intermediate value “wikified” before plugging into a filter so the proper value is used instead of the wikitext used to get that value.
There are probably some finer points that Eric or Mario or Tony could point out, but that was my thinking for my version. Glad I could help
@tw-FRed good call, I’m not yet familiar enough will all the new Transclusion options, slowly working them into existing code where I can.