[Python] How to output an empty attribute in FastHTML?

Discussão em 'Python' iniciado por Stack, Março 2, 2025.

  1. Stack

    Stack Membro Participativo

    In FastHTML I want to output <option value="">(select)</option>. However, this code…

    from fasthtml.core import to_xml
    from fasthtml.components import Option
    opt = Option("(select)", value="")
    print(to_xml(opt))


    …results in <option>(select)</option>. This causes the browser to use the value (select) when this option is chosen. I don't want to use 0 or - or something else, I want a truly empty value. How do I get it?

    Continue reading...

Compartilhe esta Página