Board Thread:Support Requests - Getting Technical/@comment-28251580-20190714112430

Hi,

I'm not entirely new to templates, but came across a problem I can't seem to solve. It is about a spoiler template. Instead of only showing/hiding spoilertext, it should have a second parameter with an ID it can insert into the HTML so every spoilerbox with the same ID can be collapsed/uncollapsed at the same time, but those with a different ID would only be uncollpased when clicked on them.

The following test cases should all work, is that even possible?

To sum it up, The spoilertext is mandatory and can be used with and without being named. The spoilerid is not mandatory, but can be used named and unnamed. If it is not used, it should get a default value (in my tests it inserted into the HTML, which is fine. I don't care that a class has the name mw-customtoggle- as long as the rest is working.

My take on this was something along the lines of this: Show/Hide the spoiler, darnit! 

I tested it on my development wiki here and here.

Is this even possible?

In other languages (in my case primarily PowerShell) I would use Parameter Sets with default parameter values if something is not given via name or pipeline input.

Reason for this is that we want to update our old Spoiler template that for now only accepts unnamed spoilertext parameter. But for some pages we came to the conclusion that it is not in the best interest of the reader if one spoilerbox would reveal each and every other spoiler on the page. I could go through the entire wiki with a bot, but I find this solution far more elegant.

Any help is kindly appreciated, thanks!  