-
Notifications
You must be signed in to change notification settings - Fork 505
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
Switch templates via query string parameters #201
Conversation
Thanks @jtpio! I wonder if we could drop the list of allowed templates and just let users select any installed template from the url params. The |
👍 |
Yes absolutely. |
45462c5
to
34bf7b1
Compare
Pushed new changes to:
|
34bf7b1
to
60251f7
Compare
60251f7
to
9f0a0e1
Compare
58f3a47
to
c554241
Compare
templates = self.nbconvert_template_paths | ||
if self.voila_configuration.template: | ||
# prioritize paths based on the template name if specified | ||
templates = sorted(self.nbconvert_template_paths, key=lambda p: -(template_name in p)) |
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.
This sorted
call feels bad to me... I suppose we should collect the right template paths for each request. See #258
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.
I suppose something cleaner and safer would be templates = collect_template_paths(..., template_name=...)
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.
Agree it's not very elegant.
Would need to check how nbconvert handles templates that make use of inheritance.
c554241
to
d15d0fc
Compare
It is cool but I think it is not a proper place to specify notebook specific template parameters. |
I think both options should be possible, but I agree that a user specifying a template should be possible to disable. |
Closes #188 |
Fixed by #637 |
A proof of concept for switching templates on the fly via the notebook metadata and query string parameters.
Related to #188 and #105.
Rename the cli parametertemplate
totemplates
to pass a list of available templates (instead of a single one)Fetchtemplate
from the notebook metadatatemplate
from the query string parametersOne thing I'm not super happy with is the need to sort the
nbconvert_template_paths
list before passing it to the nbconvert exporter.Also this approach might be completely invalidated if / when the template mechanism is changed for the next release.