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.tplto ->$prefix/share/jupyter/templates/voila/<name>/index.html$prefix/jupyter/voila/templates/<name>/staticto ->$prefix/share/jupyter/templates/voila/<name>/resourcesVoila.nbconvert_template_pathsandVoila.server_template_pathsbecomesVoila.template_pathsCons
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.htmlthat some editor/extensions support to give jinja2 syntax highlighting.TODO