Skip to content

Commit

Permalink
Create state.template on access
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Apr 30, 2021
1 parent aabc1ef commit e4e8722
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
13 changes: 6 additions & 7 deletions panel/io/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,14 +351,13 @@ def session_args(self):

@property
def template(self):
from ..config import config
if self.curdoc in self._templates:
return self._templates[self.curdoc]

@template.setter
def template(self, template):
if self.curdoc is None:
raise ValueError("Can not set template when state.curdoc is None.")
self._templates[self.curdoc] = template
template = self._templates[self.curdoc]
else:
template = config.template(theme=config.theme)
self._templates[self.curdoc] = template
return template

@property
def user(self):
Expand Down
10 changes: 3 additions & 7 deletions panel/viewable.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,9 @@ def servable(self, title=None, location=True, area='main'):
if isinstance(handler, logging.StreamHandler):
handler.setLevel(logging.WARN)
if config.template:
if state.template:
template = state.template
if template.title == template.param.title.default and title:
template.title = title
else:
params = {'title': title} if title else {}
state.template = template = config.template(theme=config.theme, **params)
template = state.template
if template.title == template.param.title.default and title:
template.title = title
if area == 'main':
template.main.append(self)
elif area == 'sidebar':
Expand Down

0 comments on commit e4e8722

Please sign in to comment.