-
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
Refactor template system #208
Refactor template system #208
Conversation
a05cb6c
to
44b0402
Compare
be23a72
to
8599a92
Compare
Trying to come up with a case where this might break:
Which file will
And what about the JS file? Should it resolve to the alice or bob version?
|
Just to clarify example 1: I think the resolution here is determined by the OS sorting of the search paths. |
I tried this refactored version of the template system, see https://github.com/martinRenou/voila-material/pull/1. It seems to work perfectly, apart from the |
Indeed, but it's determined by the application, for instance, in voila we call:
For template 'foo', such that voila will 'override' nbconvert. In your case, the apllication 'bob' would call:
Does that make sense? |
It should go to the bob/default/some.js file since the bob directory has higher precedence than alice (assuming my previous comment/code). We had a talk about it this afternoon, I think the behavior we want is very intuitive, so it behaves as you expect, still, it is very difficult to explain (which I don't like). |
I still have issues wit this design:
with this proposal, both nbconvert and voila will add "templates" in
Both are jinja (and I agree they should all use the .html extension), but they are not rendered at the same point and don't have access to the same python variables. Placing them in the same directory may be confusing for voila template authors. |
Another proposal could be
But beyond that, we should probably not try to make voila and nbconvert converge on this.
Then we could modify the
A way to do this could be to allow users to not provide a |
I think we should, it hurts my puristic me, but practical me wins here. I think 90% of the people just want to modify existing templates, and will not care nor understand the difference. Most people will fiddle with the html, and will just modify tree.html and index.html to look similar, and skim over the jinja stuff. I think this setup will actually allow static html (nbconvert) and voila templates to be very similar. For instance if we put the file 'style.css' at We can do from ....
<% block css %>
<style>
{% include "resources/style.css" %}
<style>
<% endblock css %>
.... And make it voila compatible by putting in file <% extend nbconvert/foo/index.html %>
<% block css %>
<style src="static/style.css" %}
<style>
<% endblock css %> And make voila server the resources directory under static (which I think we should rename to resources to make it all simpler/consistent) This way we can have many templates that inline the css/js to have a single html file, while voila serves them, with minimal pain. It does require clear documentation on which template has which variables available, but I think the convenience wins here. |
Even ourselves got confused about it in the early days of voila when all was in the same directory. I am not really sure this change really makes things more convenient. How about a dedicated discussion about this tomorrow? I may have another approach that may reconcile us. |
NOTE: these comments were written after a long live discussion, but still submitted for a complete history of the train of thought.
|
After a long discussion, we found some middle ground:
Basically, the rename is:
The reasoning behind it being that these are application specific directories, and we are not claiming to have a 'Jupyter template system'. It means the extends path will be a bit longer, e.g. |
5f7601e
to
9347e75
Compare
1ebebfa
to
c3063c4
Compare
c3063c4
to
f4598ce
Compare
7fe3aa9
to
e76fdb9
Compare
e676e5b
to
4123c82
Compare
The classic template does not render widgets correctly with voila, while it does with nbconvert. The reason is that with nbconvert we get the widgets from the CDN, which include all css variables. If we use voila, we rely on voila.js, which does not include all css variables. A possible solution could be to generate two bundles. |
00129f8
to
5e2f50f
Compare
…ory, and add subdirectory to search path
e7eeec1
to
af608ae
Compare
* Fix notebook_execute * Add kernel_id back
af608ae
to
b912f2d
Compare
cc @t-makaro @MSeal
This is a proof of concept of the template system for both voila and nbconvert.
voila's current layout is:
the new layout I propose is:
The search path for jinja2 will be (when --template=mycustom:
Breaking changes
$prefix/jupyter/voila/templates/<name>/nbconvert_templates/voila.tpl
to ->$prefix/share/jupyter/templates/voila/<name>/index.html
$prefix/jupyter/voila/templates/<name>/static
to ->$prefix/share/jupyter/templates/voila/<name>/resources
Voila.nbconvert_template_paths
andVoila.server_template_paths
becomesVoila.template_paths
Cons
There can be confusion about the variables available for the templates, index.html for instance goes through nbconvert, while tree.html goes through tornado.
Pros
.html
(and.tex
) gives syntax highlighting. @MSeal suggested using.j2.html
that some editor/extensions support to give jinja2 syntax highlighting.TODO