Programmatically creating dash layouts from html

Has anyone else tried programatically creating html components for a layout from an html file? What are your thoughts?

I have tried this in order to experiment with more complex layouts in Dash e.g. by copying some elements of the
Gentelella. I have written a script that converts an html doc in to Dash html components using a custom html parser and inserts the content in to a scripts app layout. The layout lpoks clear and consistent and sometimes works but I am having some issues - i strongly suspect they are string encoding issues that i need to learn more about.

I am wondering what others have experienced with this process and whether it worked for them?

1 Like

You could use beautifulsoup4 to parse the html and create a component tree from that.

Hi @Philippe,

Yes I’ve done exactly that and it works very well. I serve a page in django, edit the layout using the inspect tool in Chrome, then parse it using a combination of BeautifulSoup and a custom html parser. It finds the appropriate layout function and replaces it with the new code.

I never look at the dash layout anymore and use call backs to create content. There is a downside that i have to suppress call back exceptions for advanced layouts but works well for me and i can now have complex layouts.

If enough demand i can share the code but note it’s tailored to use with Django so needs tweaking slightly for a use case.

That’s interesting.
It’s easier writing web page in html than by using dash_html_components.
A question.
How did you do if you need components in dash_core_components?