Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have the h2 { } syntax support tag params #231

Open
owengray-google opened this issue Jul 20, 2023 · 0 comments
Open

Have the h2 { } syntax support tag params #231

owengray-google opened this issue Jul 20, 2023 · 0 comments

Comments

@owengray-google
Copy link

The FlowOrHeadingContent.h1 method can accept class as an argument, but not other parameters.

In general, we want to pass through all or most parameters unchanged.
The ideal syntax that maintains back-compatability would likely be an overload

inline fun FlowOrHeadingContent.h1(classes : String? = null, crossinline block : H1.() -> Unit = {}) : Unit = H1(attributesMapOf("class", classes), consumer).visit(block)
/** New overload: */
inline fun FlowOrHeadingContent.h1(params : Map<String, String> = null, crossinline block : H1.() -> Unit = {}) : Unit = H1(params, consumer).visit(block)

We can and have just manually inlined the current h1, but I think supporting more params in what seems to be the recommended API would be more correct.

This does not just apply to headings, but to many of the functions like this.
Specifically, we have needed to do this to allow setting id attributes for headings, which is used for tables of contents and to allow the headings to work as link anchors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant