silverbulletmd / silverbullet

The hackable notebook
https://silverbullet.md
MIT License
2.01k stars 138 forks source link

Makes the behaviour of logic expressions consistent in all cases #898

Open MrMugame opened 1 week ago

MrMugame commented 1 week ago

This fixes #894. I also removed the legacy call syntax handling, because it caused problems where an expression like this a or b was turned into a (or b), which just doesn't make sense. Personally I'm for deprecating that call syntax as I don't really see a reason to keep it. If it should stay I would add it directly into the grammar to avoid any ambiguities like that.

zefhemel commented 1 week ago

I'm ok with this. I added it to make the transition from handlebars easier, but that happened a while ago now so maybe it's time to drop it.

I don't have access to a proper device for a while (vacation), so a few things are harder to check:

zefhemel commented 1 week ago

So looks like you found some uses. Which means practically all people will have broken templates if they don't reimport the Core library. Really need a way a solution to library updates or rather lack thereof before merging this I fear.

MrMugame commented 1 week ago

Actually we can partially keep the old syntax. I haven't found any occurences of the old call syntax in the library, where arguments were passed. Only without arguments and that is already not handled as a call.

let attrVal = attributeVal[val[1]];
const func = functionMap[val[1]];
if (attrVal === undefined && func !== undefined) {
  // Fallback to function call, if one is defined with this name
  attrVal = func(variables);
}
return attrVal;

So we can keep that and only remove the syntax with arguments, which actually seems like a pretty good way. (Just noticed that now, that's why Im reverting)

zefhemel commented 5 days ago

I'll probably merge this when I come home next week. Would like to test it a bit first and make sure we understand all implications.

MrMugame commented 5 days ago

Do we want to add a null coalesce operator (??) ?

zefhemel commented 4 days ago

I don't have anything against it. Why not