Open Jermolene opened 2 years ago
Yea, ... On the other hand from time to time users request an If-then-else construction similar to the condition plugin
It would be a convenience function instead of the need to use the list-widget.
Yea, ... On the other hand from time to time users request an If-then-else construction similar to the condition plugin
Indeed, but such a thing belongs in the core, or its own plugin, and wouldn't be appropriate for this docs plugin.
Indeed, but such a thing belongs in the core, or its own plugin, and wouldn't be appropriate for this docs plugin.
So should we create a PR using the condition plugin code?
As far as I can remember, the widgets have to follow a specific syntax pattern to work as intended. eg: JS syntax used to describe the problem
// the following syntax is OK
if (var === true) {
// do something
} else {
// do something else
}
// The following syntax in _wrong_
if (var === ture) {
// do something
}
var x = y;
else {
// do something else
}
In JS it's clear, that we get a syntax error.
But the same problem happens if we use "faulty syntax" in wikitext, which would be a new behaviour.
<!-- this does work -->
<$list filter="false">
<!-- do something -->
</list>
<br>
<$else> <!-- do something --> </$else>
This is a difference in behaviour of widgets, since the else-widget needs to "find" it's related sibling. ... I'm only 90% sure that I got the problem right. ... The plugins where created in 2017 ...
Indeed, but such a thing belongs in the core, or its own plugin, and wouldn't be appropriate for this docs plugin.
So should we create a PR using the condition plugin code?
Let's discuss a potential if/then/else solution in a new issue. All we need to worry about here is that we can refactor out the current usages of the .if
macro.
There is a simple JavaScript macro that has been used in the documentation since 2015:
https://github.com/Jermolene/TiddlyWiki5/blob/master/editions/tw5.com/tiddlers/system/if-macro.js
It should now be possible to replace it with a wikitext construction.