fasthtml

How to pass on raw html in FastHTML


I'm trying to handle raw html and pass it onto fasthtml


from fasthtml.common import *
...

@rt('/test/')
def test():
    raw_content1 = "<button>button 1</button>"
    return Div( ft_html(raw_content1) )

getting this instead of a div wrapped button

 <div>
<<button>button 1</button>></<button>button 1</button>>     </div>

enter image description here

How do I properly handle that in FastHTML?


Solution

  • you can use NotStr:

    from fasthtml.common import *
    ...
    
    @rt('/test/')
    def test():
        raw_content1 = "<button>button 1</button>"
        return Div( NotStr(raw_content1) )