-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assets files & index customizations #286
Changes from 1 commit
53ec2ef
a14709a
69b8adc
7cafb47
7ebab39
fc26544
d2cce95
1212ee5
846c8fc
4777731
23195f0
0c96dc7
f943471
cd0c15c
0d9151c
ff1cff3
eaf91a1
2197e38
ea0d2ca
4cf9e5c
f6e9922
8cc781b
0046402
6af0381
2c104a5
1171f0a
cd4cfa9
495762e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -419,6 +419,42 @@ def index(self, *args, **kwargs): # pylint: disable=unused-argument | |
def interpolate_index(self, | ||
metas='', title='', css='', config='', | ||
scripts='', app_entry='', favicon=''): | ||
""" | ||
Called to create the initial HTML string that is loaded on page. | ||
Override this method to provide you own custom HTML. | ||
|
||
:Example: | ||
|
||
class MyDash(dash.Dash): | ||
def interpolate_index(self, **kwargs): | ||
return ''' | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>My App</title> | ||
</head> | ||
<body> | ||
<div id="custom-header">My custom header</div> | ||
{} | ||
{} | ||
{} | ||
<div id="custom-footer">My custom footer</div> | ||
</body> | ||
</html> | ||
'''.format( | ||
kwargs.get('app_entry'), | ||
kwargs.get('config'), | ||
kwargs.get('scripts')) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd have a preference for using named interpolations here, as I think this is good practice for such a long string being interpolated. eg |
||
:param metas: Collected & formatted meta tags. | ||
:param title: The title of the app. | ||
:param css: Collected & formatted css dependencies as <link> tags. | ||
:param config: Configs needed by dash-renderer. | ||
:param scripts: Collected & formatted scripts tags. | ||
:param app_entry: Where the app will render. | ||
:param favicon: A favicon <link> tag if found in assets folder. | ||
:return: The interpolated HTML string for the index. | ||
""" | ||
return _interpolate(self.index_string, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's probably not enough error-checking here... Shouldn't we raise a very helpful and clear message if they forget to add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two options I thought of:
Which would be best ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would actually do both :) That way it fails fast for those using |
||
metas=metas, | ||
title=title, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's include a quick docstring for our users. Something like:
(but with the example filled out)