Right now the rendering of the dash index is done with a simple string formatting.
This is not ideal, flask is shipped with jinja2 and we should use it to render the
dash index page instead.
Pros:
- Easier to change.
- Easier to read.
- Easily expandable.
- Safer formatting.
- Extendable by the user.
- Context variables.
- Blocks
Cons:
Here's the template I've come up with on branch jinja-index-render:
<!DOCTYPE html>
<htmllang="{{ lang }}">
<head>
<metacharset="UTF-8">
{%blockmeta_tags%}{%formetainmetas%}
<metaname="{{ meta.name }}"content="{{ meta.content }}" >
{%endfor%}{%endblock%}
<title>{{ title }}</title>
{%blockcss_files%}{%iffavicon%}
<linkrel="shortcut icon"href="{{ favicon }}"type="image/x-icon">
{%endif%}{%forcincss_files%}
<linkrel="stylesheet"href="{{ c | safe }}">
{%endfor%}{%endblock%}
</head>
<body>
{%blockheader%}{%endblock%}{%blockreact_entry_point%}
<divid="react-entry-point">
<divclass="_dash-loading">
Loading...
</div>
</div>
{%endblock%}
<footer>
<scriptid="_dash-config"type="application/json">{{ configs | safe }}</script>
{%forsrcinscripts_files%}
<scriptsrc="{{ src | safe }}"></script>
{%endfor%}{%blockfooter%}{%endblock%}
</footer>
</body>
</html>This template can be overridden by the user by changing the config of dash.
app = dash.Dash(index_template='home.html')
The user can then modify blocks as he wishes:
{%extends'index.html'%}{%blockheader%}
<div>My Project header</div>
{%endblock%}I'd like feedback on this, this is a step I want to take before adding new features such as #265 and #66.
Right now the rendering of the dash index is done with a simple string formatting.
This is not ideal, flask is shipped with jinja2 and we should use it to render the
dash index page instead.
Pros:
Cons:
Here's the template I've come up with on branch
jinja-index-render:This template can be overridden by the user by changing the config of dash.
app = dash.Dash(index_template='home.html')The user can then modify blocks as he wishes:
I'd like feedback on this, this is a step I want to take before adding new features such as #265 and #66.