8000 Allow passing multiple attrs args into components by gazpachoking · Pull Request #117 · pelme/htpy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Allow passing multiple attrs args into components #117

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

Merged
merged 4 commits into from
May 25, 2025

Conversation

gazpachoking
Copy link
Contributor
@gazpachoking gazpachoking commented May 20, 2025

Allows passing more than one dict of arguments into an element. Can be useful if you have a helper function that generates a single attribute. This would let you use that helper more than once on the same element.

Also simplified to only use 2 overloads for typing BaseElement.__init__

Copy link
Owner
@pelme pelme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice, thanks!

can you also add:

  • a note about this change in the changelog?
  • an example of using multiple dicts to the usage docs?

once starfederation/datastar#902 is merged, feel free to submit a PR which links to it from the docs. I think it is a great example of using a custom helper to create specific attributes for a library. I am thinking about doing something similar for htmx and alpine.js. we could potentially add htpy-htmx, htpy-alpinejs etc projects with just helpers that create useful dicts of attributes.

@pelme
Copy link
Owner
pelme commented May 24, 2025

Someone else was running into similar problems:

https://www.reddit.com/r/htmx/comments/1kantse/comment/mpxh5jv/

I really think we need to improve the docs here :)

@gazpachoking
Copy link
Contributor Author

Okay, fixed up that list call and added a tiny bit of docs.

Someone else was running into similar problems:

https://www.reddit.com/r/htmx/comments/1kantse/comment/mpxh5jv/

I really think we need to improve the docs here :)

I didn't quite get their need, unless they were over complicating it. Was it just working around not being able to pass in multiple attribute dicts?

@gazpachoking gazpachoking force-pushed the multiple-attrs-args branch from b70ab00 to 5e46be7 Compare May 25, 2025 00:12
@pelme
Copy link
Owner
pelme commented May 25, 2025

Okay, fixed up that list call and added a tiny bit of docs.

Someone else was running into similar problems:
8000 https://www.reddit.com/r/htmx/comments/1kantse/comment/mpxh5jv/
I really think we need to improve the docs here :)

I didn't quite get their need, unless they were over complicating it. Was it just working around not being able to pass in multiple attribute dicts?

Yes I think it looks a bit over complicated. Being able to pass multiple dicts of attributes seems like an easy way to combine them and your docs example show how.

Hopefully we can get a community going of helpers that generate attribute dicts that can then be combined :)

@pelme pelme merged commit 7d6fe4f into pelme:main May 25, 2025
14 checks passed
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

Successfully merging this pull request may close these issues.

2 participants
0