[plugins] Work around blueprint templates (web UI) sharing a namespace
This commit is contained in:
parent
a63730fe86
commit
ba0b8c1068
2 changed files with 12 additions and 1 deletions
src/ovtk_audiencekit
|
@ -29,6 +29,17 @@ class OvtkBlueprint(quart.Blueprint):
|
|||
endpoint = self.name + endpoint
|
||||
return quart.url_for(endpoint, *args, **kwargs)
|
||||
|
||||
def render(self, name, **kwargs):
|
||||
"""render_template that prefers the plugin-specific templates"""
|
||||
full = self.template_folder / name
|
||||
if os.path.exists(full):
|
||||
template_string = None
|
||||
with open(full, 'r') as template_file:
|
||||
template_string = template_file.read()
|
||||
return quart.render_template_string(template_string, **kwargs)
|
||||
else:
|
||||
return quart.render_template(name, **kwargs)
|
||||
|
||||
|
||||
class PluginBase(ABC):
|
||||
plugins = {}
|
||||
|
|
|
@ -138,7 +138,7 @@ class ScenePlugin(PluginBase):
|
|||
|
||||
async def ui_ctrlpanel(self):
|
||||
groups = self._get_state()
|
||||
return await quart.render_template('index.html', init_state=json.dumps(groups))
|
||||
return await self.blueprint.render('index.html', init_state=json.dumps(groups))
|
||||
|
||||
async def ui_setscene(self, name=None, cmd=None):
|
||||
active = cmd == 'activate'
|
||||
|
|
Loading…
Add table
Reference in a new issue