Skip to content
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

Allow adding Location to BasicTemplate #1638

Merged
merged 1 commit into from
Oct 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions panel/template/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@

class BaseTemplate(param.Parameterized, ServableMixin):

location = param.Boolean(default=False, doc="""
Whether to add a Location component to this Template.
Note if this is set to true, the Jinja2 template must
either insert all available roots or explicitly embed
the location root with : {{ embed(roots.location) }}.""")

# Dictionary of property overrides by bokeh Model type
_modifiers = {}

Expand Down Expand Up @@ -124,6 +130,9 @@ def _apply_root(self, name, viewable, tags):
def _init_doc(self, doc=None, comm=None, title=None, notebook=False, location=True):
doc = doc or _curdoc()
title = title or 'Panel Application'
if location and self.location:
loc = self._add_location(doc, location)
doc.on_session_destroyed(loc._server_destroy)
doc.title = title
col = Column()
preprocess_root = col.get_root(doc, comm)
Expand Down Expand Up @@ -334,6 +343,8 @@ class BasicTemplate(BaseTemplate):
theme = param.ClassSelector(class_=Theme, default=DefaultTheme,
constant=True, is_instance=False, instantiate=False)

location = param.Boolean(default=True, readonly=True)

_css = None

_template = None
Expand Down Expand Up @@ -383,9 +394,6 @@ def _css_files(self):

def _init_doc(self, doc=None, comm=None, title=None, notebook=False, location=True):
doc = super(BasicTemplate, self)._init_doc(doc, comm, title, notebook, location)
if location:
loc = self._add_location(doc, location)
doc.on_session_destroyed(loc._server_destroy)
if self.theme:
theme = self.theme.find_theme(type(self))
if theme and theme.bokeh_theme:
Expand Down