Twine Version: 2.9.2.0
Hi, so I am getting into using widgets as I realized that JS document.createElement is extremely tedious and widgets are kinda like react elements (for my web devs). But, for some reason, I can’t figure this one issue out, which I assume by the SugarCube documentations, is quite possible. For clarification, I have made other (even technically more complex) widgets that work fine, fetching a variable based on some value I gave it, so I am genuinely confused why this is the thing that is driving me crazy.
I have a very simple widget for creating a with some text that has a required class, and then an optional (arg) to add an additional class:
<<widget "altsystemtxt" container>>
<<set _classes = _args[0] ? "textSystem " + _args[0] : "textSystem" >>
<span @class="_classes"> _contents </span>
<</widget>>
And then I’d call it with (example):
<<altsystemtxt "error">>The World Happiness Percentage has fallen below the minimum value to keep this world functioning.<</altsystemtxt>>
I’ve logged it to the console and saw that _args was not undefined (nor _args[0]), and definitely existed. I have also tried setting the class directly to args[0] and brings up the same error:
Error: <<altsystemtxt>>: error within widget code ( The World Happiness Percentage has fallen below the minimum value to keep this world functioning. )
Though, to point out, the one time I didn’t have an error was when I didn’t separate “textSystem” and _args[0], so the class became “textSystemerror” and adding a space to make it "textSystem " caused the error too.
I honestly have no idea what this could mean. I also tried adding more quotes, changing to single, etc. based on the docs for widgets, but I still can’t figure it out.
So, what exactly am I missing?