From what I recall of the $importvariables widget it only works under a pretty narrow set of conditions (only $set widgets in the parse tree). I believe the presence of the import pragma in the tiddler that is being imported from, is causing the import to fail.
There seems to be a problem, if the tiddler that is imported also contains an <$importvariables widget. … The parse-tree, seems to contain the macro definition, but the while loop doesn’t find it.
Edit $:/core/save/all2 and remove the \import pragma from the first line
Then, I tried:
<$importvariables filter="$:/core/save/all2">
saveTiddlerFilter is: <$text text=<<saveTiddlerFilter>>/><br>
</$importvariables>
and it displays the value of <<saveTiddlerFilter>>!!!
Of course, this isn’t really a solution for my purpose, since I am trying to get the value directly from the shadow tiddler, and cloning the shadow isn’t really a viable option. My current workaround is to simply copy the definition of <<saveTiddlerFilter>> from $:/core/save/all and just paste it into my code. Of course, if the TWCore shadow definition is ever changed, I’ll have to remember to update the copy in my code to match the new TWCore definition.
I cannot think of a clean solution either at the moment and it would be worth giving some thought to how we could refactor the core template for reusability.
Regarding the behaviour of $importvariables, I cannot look at the source code at the moment but as I recall, the $importvariables widget assumes the parse tree starts with a $set widget and any children of that first $set widget are also $set widgets (which includes macros). Any sibling $set widgets of the first $set are also ignored. Not very intuitive and something we are tied to by backwards compatibility.
It’s tricky. $:/core/save/all needs the \import pragma, because of the $(publishFilter)$ variable substitution in the saveTiddlerFilter macro. … So if the macro should be resolved in the right way, we would need to evaluate the $importvariables widget recursively
If we could solve the $(publishFilter)$ problem in a different way, the \import pragma could be removed again.
That is correct: <$importvariables> only imports <$set> widgets, and doesn’t recognise <$importvariables>, <$vars>or <$let>. I don’t think we could change it without breaking strict backwards compatibility, but it would be very useful.
Any sibling $set widgets of the first $set are also ignored. Not very intuitive and something we are tied to by backwards compatibility.
It’s not obvious what if anything we could do with such sibling widgets. Hoisting them up into the first $set widget would change the semantics.