Dynamically building html elements #499
Unanswered
csmiller34
asked this question in
Q&A
Replies: 1 comment
-
I created a list of the options I needed and included the result in the select object:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
For a simple element like a , the fasthtml examples show hard-coded options. For example, return Body(P( Select(id="attr1st")( Option("first value), Option("second value) ) )) What if I want to dynamically add the options? I was looking at a pypi library called airium which is similar in that you chain html elements together as part of the return but it lets you mix in python scripting with the html elements. The above example might look like this: a = airium() with a.body(): with a.p(): with a.select(id="attr1st"): for option in options: a.option(_t=option['label']) return str(a) Is there a similar way to do this in FastHTML or is there a different approach?
Beta Was this translation helpful? Give feedback.
All reactions