I expect it to give me the opening tag only, as written. I’m finding, though, that it gives me both the opening and the closing details tag.
I’m wondering how I could turn this off, or if I should approach this a different way. I’m wanting to add the “open” attribute depending on the value of one of the fields of the current tiddler.
In some ways you have not fully specified your problem, class definition etc… but other methods exist. Please come back and let us know if the details widget was enough!
You can set a button to be a details tag, and toggle the content with a reveal widget. Same effect, but you get the benefit to use animations too while using standard html elements
It seems like chrome handle display:contents for the detail element differently than firefox, on firefox this can be used to disable the toggle behavior of the details element and this allows to use animation… not sure how to fix that/ if it’s possible to fix
Might be best to just use a button element and style it like a details element ?
Wouldn’t it be nice if the contents of the $macrocall widget could be passed as a named parameter, e.g. widget-content, to the macro? This way one could wrap any amount of text within the $macrocall and let the macro wrap it with opening and closing tags or hide it or do whatever with it.
Depending on the unknown details of the OP’s problem, that might be useful in this case, or not. Would be nice to have anyway, though…
Thanks to all who have responded! Here is my code in full. I want to be able to open and close all the details elements with a click of a button. This works, but not when I open one individually.
Here’s an example. First there’s a procedure definition (they are a replacement for macros that don’t do textual substitution of their parameters). It includes a <$slot> widget that defines the position in which the content will be grafted:
Secondly, we invoke the procedure, but not with the <$macrocall> widget. Instead, in the PR the <$transclude> widget has been extended to be able to transclude variables, which is all that <$macrocall> ever did.
I am looking forward to reading the docs page describing all this new syntax to us old-timers…
Gonna grab a pot of coffee and spend the evening reading through that PR. Or maybe the next morning.
What I’m running into now is that when the detailState macro is rendered, it is expanding the Boolean attribute “open” into “open=true”. Thus when I have collapsed all of my details elements via a TW button but open one of them with the native disclosure widget, I can get a state like this:
I am hoping to make use of the native HTML display routine. Although this details element is a very peculiar HTML element, and is almost a widget of its own.