It’s a complex question. So first here is some code that may work for you:
\function slug(title) [<title>split[-]first[]]
<$transclude $variable=slug title={{!!title}}/>
or
<$transclude $variable=slug title=<<currentTiddler>>/>
- Functions are like filter runs So your
[<<tiddlerTitle>>notation is invalid. It would need to be:[<tiddlerTitle> - Functions can not have a
<$parameter >widget inside their code block. They are “filter strings” only. - Functions only return the first element if the filter string would actually create several elements.
There will be a second post, but I have to think about that one.
Probably related: TW Variables Have a Scope and can be "Stacked" – Not sure if that one will help you.