There is no clear way mentioned in the documentation and your solution will work but is indeed not very elegant. My own preferred solution is to use currying in the script block itself.
const handleClick = (parameter) => () => {
// actual function
}
And in the HTML
<button on:click={handleClick('parameter1')>
It works...
</button>
Beware of currying
As mentioned in the comments, currying has its pitfalls. The most common one that in the above example handleClick('parameter1')
will not be fired when clicking but rather on rendering, returning a function that in turn will be fired onclick. This means that this function will always use 'parameter1' as it's argument.
Therefore using this method would only be safe if the used parameter is a constant of some kind and will not change once it's rendered.
This would bring me to another point:
1) If it's a constant used a parameter, you could as well use a seperate function
const handleParameter1Click = () => handleClick('parameter1');
2) If the value is dynamic but available within the component, this could still be handled with a standalone function:
let parameter1;
const handleParameter1Click = () => handleClick(parameter1);
3) If the value is dynamic but not available from the component because this is dependent on some kind of scope (eg: a list of items rendered in a #each block) the 'hacky' approach will work better. However I think it would be better to in that case have the list-elements as a component themselves and fall back to case #2
To conclude: currying will work under certain circumstance but is not recommended unless you are very well aware and careful about how to use it.