##// END OF EJS Templates
Simplification of the logic.
damianavila -
Show More
@@ -1,179 +1,165 b''
1 1 {%- extends 'display_priority.tpl' -%}
2 2
3 3
4 4 {% block codecell %}
5 5 <div class="cell border-box-sizing code_cell">
6 6 {{ super() }}
7 7 </div>
8 8 {%- endblock codecell %}
9 9
10 10 {% block input_group -%}
11 11 <div class="input">
12 12 {{ super() }}
13 13 </div>
14 14 {% endblock input_group %}
15 15
16 {% block m_input_group -%}
17 <div class="input">
18 {{ super() }}
19 </div>
20 {% endblock m_input_group %}
21
22 {% block h_input_group -%}
23 <div class="input">
24 {{ super() }}
25 </div>
26 {% endblock h_input_group %}
27
28 {% block r_input_group -%}
29 {{ super() }}
30 {% endblock r_input_group %}
31
32 {% block u_input_group -%}
33 {{ super() }}
34 {% endblock u_input_group %}
35
36 16 {% block output_group %}
37 17 <div class="output_wrapper">
38 18 <div class="output">
39 19 {{ super() }}
40 20 </div>
41 21 </div>
42 22 {% endblock output_group %}
43 23
44 24 {% block in_prompt -%}
45 25 <div class="prompt input_prompt">
46 26 In&nbsp;[{{ cell.prompt_number }}]:
47 27 </div>
48 28 {%- endblock in_prompt %}
49 29
50 30 {% block e_in_prompt -%}
51 31 <div class="prompt input_prompt">
52 32 </div>
53 33 {%- endblock e_in_prompt %}
54 34
55 35 {#
56 36 output_prompt doesn't do anything in HTML,
57 37 because there is a prompt div in each output area (see output block)
58 38 #}
59 39 {% block output_prompt %}
60 40 {% endblock output_prompt %}
61 41
62 42 {% block input %}
63 43 <div class="input_area box-flex1">
64 44 {{ cell.input | highlight2html(metadata=cell.metadata) }}
65 45 </div>
66 46 {%- endblock input %}
67 47
68 48 {% block output %}
69 49 <div class="output_area">
70 50 {%- if output.output_type == 'pyout' -%}
71 51 <div class="prompt output_prompt">
72 52 Out[{{ cell.prompt_number }}]:
73 53 {%- else -%}
74 54 <div class="prompt">
75 55 {%- endif -%}
76 56 </div>
77 57 {{ super() }}
78 58 </div>
79 59 {% endblock output %}
80 60
81 {% block m_input %}
61 {% block markdowncell scoped %}
62 <div class="input">
63 {{ self.e_in_prompt() }}
82 64 <div class="inner_cell">
83 65 <div class="text_cell_render border-box-sizing rendered_html">
84 66 {{ cell.source | markdown2html | strip_files_prefix }}
85 67 </div>
86 68 </div>
87 {%- endblock m_input %}
69 </div>
70 {%- endblock markdowncell %}
88 71
89 {% block h_input %}
72 {% block headingcell scoped %}
73 <div class="input">
74 {{ self.e_in_prompt() }}
90 75 <div class="inner_cell">
91 76 <div class="text_cell_render border-box-sizing rendered_html">
92 77 {{ ("#" * cell.level + cell.source) | replace('\n', ' ') | markdown2html | strip_files_prefix | add_anchor }}
93 78 </div>
94 79 </div>
95 {% endblock h_input %}
80 </div>
81 {% endblock headingcell %}
96 82
97 {% block r_input %}
83 {%- block rawcell scoped -%}
98 84 {% if cell.metadata.get('raw_mimetype', resources.get('raw_mimetype', '')).lower() in resources.get('raw_mimetypes', ['']) %}
99 85 {{ cell.source }}
100 86 {% endif %}
101 {% endblock r_input %}
87 {%- endblock rawcell -%}
102 88
103 {% block u_input %}
89 {% block unknowncell scoped %}
104 90 unknown type {{ cell.type }}
105 {% endblock u_input %}
91 {% endblock unknowncell %}
106 92
107 93 {% block pyout -%}
108 94 <div class="box-flex1 output_subarea output_pyout">
109 95 {% block data_priority scoped %}
110 96 {{ super() }}
111 97 {% endblock %}
112 98 </div>
113 99 {%- endblock pyout %}
114 100
115 101 {% block stream_stdout -%}
116 102 <div class="box-flex1 output_subarea output_stream output_stdout">
117 103 <pre>
118 104 {{ output.text | ansi2html }}
119 105 </pre>
120 106 </div>
121 107 {%- endblock stream_stdout %}
122 108
123 109 {% block stream_stderr -%}
124 110 <div class="box-flex1 output_subarea output_stream output_stderr">
125 111 <pre>
126 112 {{ output.text | ansi2html }}
127 113 </pre>
128 114 </div>
129 115 {%- endblock stream_stderr %}
130 116
131 117 {% block data_svg -%}
132 118 {{ output.svg }}
133 119 {%- endblock data_svg %}
134 120
135 121 {% block data_html -%}
136 122 <div class="output_html rendered_html">
137 123 {{ output.html }}
138 124 </div>
139 125 {%- endblock data_html %}
140 126
141 127 {% block data_png %}
142 128 <img src="data:image/png;base64,{{ output.png }}">
143 129 {%- endblock data_png %}
144 130
145 131 {% block data_jpg %}
146 132 <img src="data:image/jpeg;base64,{{ output.jpeg }}">
147 133 {%- endblock data_jpg %}
148 134
149 135 {% block data_latex %}
150 136 {{ output.latex }}
151 137 {%- endblock data_latex %}
152 138
153 139 {% block pyerr -%}
154 140 <div class="box-flex1 output_subarea output_pyerr">
155 141 <pre>{{ super() }}</pre>
156 142 </div>
157 143 {%- endblock pyerr %}
158 144
159 145 {%- block traceback_line %}
160 146 {{ line | ansi2html }}
161 147 {%- endblock traceback_line %}
162 148
163 149 {%- block data_text %}
164 150 <pre>
165 151 {{ output.text | ansi2html }}
166 152 </pre>
167 153 {%- endblock -%}
168 154
169 155 {%- block data_javascript %}
170 156 <script type="text/javascript">
171 157 {{ output.javascript }}
172 158 </script>
173 159 {%- endblock -%}
174 160
175 161 {%- block display_data scoped -%}
176 162 <div class="box-flex1 output_subarea output_display_data">
177 163 {{ super() }}
178 164 </div>
179 165 {%- endblock display_data -%}
@@ -1,106 +1,94 b''
1 1 {#
2 2
3 3 DO NOT USE THIS AS A BASE,
4 4 IF YOU ARE COPY AND PASTING THIS FILE
5 5 YOU ARE PROBABLY DOING THINGS INCORRECTLY.
6 6
7 7 Null template, does nothing except defining a basic structure
8 8 To layout the different blocks of a notebook.
9 9
10 10 Subtemplates can override blocks to define their custom representation.
11 11
12 12 If one of the block you do overwrite is not a leave block, consider
13 13 calling super.
14 14
15 15 {%- block nonLeaveBlock -%}
16 16 #add stuff at beginning
17 17 {{ super() }}
18 18 #add stuff at end
19 19 {%- endblock nonLeaveBlock -%}
20 20
21 21 consider calling super even if it is a leave block, we might insert more blocks later.
22 22
23 23 #}
24 24 {%- block header -%}
25 25 {%- endblock header -%}
26 26 {%- block body -%}
27 27 {%- for worksheet in nb.worksheets -%}
28 28 {%- for cell in worksheet.cells -%}
29 29 {%- block any_cell scoped -%}
30 30 {%- if cell.cell_type in ['code'] -%}
31 31 {%- block codecell scoped -%}
32 32 {%- block input_group -%}
33 33 {%- block in_prompt -%}{%- endblock in_prompt -%}
34 34 {%- block input -%}{%- endblock input -%}
35 35 {%- endblock input_group -%}
36 36 {%- if cell.outputs -%}
37 37 {%- block output_group -%}
38 38 {%- block output_prompt -%}{%- endblock output_prompt -%}
39 39 {%- block outputs scoped -%}
40 40 {%- for output in cell.outputs -%}
41 41 {%- block output scoped -%}
42 42 {%- if output.output_type in ['pyout'] -%}
43 43 {%- block pyout scoped -%}{%- endblock pyout -%}
44 44 {%- elif output.output_type in ['stream'] -%}
45 45 {%- block stream scoped -%}
46 46 {%- if output.stream in ['stdout'] -%}
47 47 {%- block stream_stdout scoped -%}
48 48 {%- endblock stream_stdout -%}
49 49 {%- elif output.stream in ['stderr'] -%}
50 50 {%- block stream_stderr scoped -%}
51 51 {%- endblock stream_stderr -%}
52 52 {%- endif -%}
53 53 {%- endblock stream -%}
54 54 {%- elif output.output_type in ['display_data'] -%}
55 55 {%- block display_data scoped -%}
56 56 {%- block data_priority scoped -%}
57 57 {%- endblock data_priority -%}
58 58 {%- endblock display_data -%}
59 59 {%- elif output.output_type in ['pyerr'] -%}
60 60 {%- block pyerr scoped -%}
61 61 {%- for line in output.traceback -%}
62 62 {%- block traceback_line scoped -%}{%- endblock traceback_line -%}
63 63 {%- endfor -%}
64 64 {%- endblock pyerr -%}
65 65 {%- endif -%}
66 66 {%- endblock output -%}
67 67 {%- endfor -%}
68 68 {%- endblock outputs -%}
69 69 {%- endblock output_group -%}
70 70 {%- endif -%}
71 71 {%- endblock codecell -%}
72 72 {%- elif cell.cell_type in ['markdown'] -%}
73 73 {%- block markdowncell scoped-%}
74 {%- block m_input_group -%}
75 {%- block e_in_prompt -%}{%- endblock e_in_prompt -%}
76 {%- block m_input -%}{%- endblock m_input -%}
77 {%- endblock m_input_group -%}
78 74 {%- endblock markdowncell -%}
79 75 {%- elif cell.cell_type in ['heading'] -%}
80 76 {%- block headingcell scoped-%}
81 {%- block h_input_group -%}
82 {{ self.e_in_prompt() }}
83 {%- block h_input -%}{%- endblock h_input -%}
84 {%- endblock h_input_group -%}
85 77 {%- endblock headingcell -%}
86 78 {%- elif cell.cell_type in ['raw'] -%}
87 79 {%- block rawcell scoped -%}
88 80 {% if cell.metadata.get('raw_mimetype', '').lower() in resources.get('raw_mimetypes', ['']) %}
89 81 {{ cell.source }}
90 82 {% endif %}
91 83 {%- endblock rawcell -%}
92 84 {%- else -%}
93 85 {%- block unknowncell scoped-%}
94 {%- block u_input_group -%}
95 {{ self.e_in_prompt() }}
96 {%- block u_input -%}{%- endblock u_input -%}
97 {%- endblock u_input_group -%}
98 86 {%- endblock unknowncell -%}
99 87 {%- endif -%}
100 88 {%- endblock any_cell -%}
101 89 {%- endfor -%}
102 90 {%- endfor -%}
103 91 {%- endblock body -%}
104 92
105 93 {%- block footer -%}
106 94 {%- endblock footer -%}
General Comments 0
You need to be logged in to leave comments. Login now