You already wrote most of it (!?) - so is this sufficient? I’ve indented it for clarity but you can remove the indentation if you don’t like it.
\define block(span:"" tid:"")
<$list filter='[[$tid$]is[tiddler]]'>
<span class='$span$'>
<details>
<summary>
<$view tiddler='$tid$' field='title'/> <$link>*</$link>
</summary>
<span class='indent1'>
<$transclude tiddler='$tid$' field='text' mode='block'/>
</span>
</details>
</span>
</$list>
<$list filter='[[$tid$]!is[tiddler]]'>
<span class='$span$'>
<span class='missing'>
<$link to='$tid$'/>
</span>
</span>
</$list>
\end
…or, wait, you’re not asking for the various classes to be written, are you?