pelme/htpy

[question] Are elements for inline CSS?

Closed this issue · 3 comments

Thanks for this well-designed library. Is there any other way to add inline css than providing the entire css code as a string within the htpy.style element? If not, are there any plans for adding a similar python-code-based mechanism to build up inline CSS?

Thank you,
Christoph

For my use cases it has felt more straightforward to just write strings. I would be open to adding support for it if we could figure out a good use syntax for it!

htbuilder defines helpers for this: https://github.com/tvst/htbuilder?tab=readme-ov-file#styling

Do you have any ideas on how it could work?

I didn't really think about how such a solution should be designed. At least in a way that is syntactically similar to htpy-python-html code and that allows for programatically generating elements (loops, if/else, etc.). The reason I asked in the first place was that I also stumbled across htbuilder (thanks for the link) and thought maybe something like this could be already implemented in htpy - maybe with some extra library - and I just didn't see it.

This can definitely be done separately with utils/helper functions. Feel free to open a Github discussion if you figure out something useful. :)