null.j2 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. {#
  2. DO NOT USE THIS AS A BASE,
  3. IF YOU ARE COPY AND PASTING THIS FILE
  4. YOU ARE PROBABLY DOING THINGS INCORRECTLY.
  5. Null template, does nothing except defining a basic structure
  6. To layout the different blocks of a notebook.
  7. Subtemplates can override blocks to define their custom representation.
  8. If one of the block you do overwrite is not a leaf block, consider
  9. calling super.
  10. {%- block nonLeafBlock -%}
  11. #add stuff at beginning
  12. {{ super() }}
  13. #add stuff at end
  14. {%- endblock nonLeafBlock -%}
  15. consider calling super even if it is a leaf block, we might insert more blocks later.
  16. #}
  17. {%- block header -%}
  18. {%- endblock header -%}
  19. {%- block body -%}
  20. {%- block body_header -%}
  21. {%- endblock body_header -%}
  22. {%- block body_loop -%}
  23. {%- for cell in nb.cells -%}
  24. {%- block any_cell scoped -%}
  25. {%- if cell.cell_type == 'code'-%}
  26. {%- if resources.global_content_filter.include_code -%}
  27. {%- block codecell scoped -%}
  28. {%- if resources.global_content_filter.include_input and not cell.metadata.get("transient",{}).get("remove_source", false) -%}
  29. {%- block input_group -%}
  30. {%- if resources.global_content_filter.include_input_prompt -%}
  31. {%- block in_prompt -%}{%- endblock in_prompt -%}
  32. {%- endif -%}
  33. {%- block input -%}{%- endblock input -%}
  34. {%- endblock input_group -%}
  35. {%- endif -%}
  36. {%- if cell.outputs and resources.global_content_filter.include_output -%}
  37. {%- block output_group -%}
  38. {%- if resources.global_content_filter.include_output_prompt -%}
  39. {%- block output_prompt -%}{%- endblock output_prompt -%}
  40. {%- endif -%}
  41. {%- block outputs scoped -%}
  42. {%- for output in cell.outputs -%}
  43. {%- block output scoped -%}
  44. {%- if output.output_type == 'execute_result' -%}
  45. {%- block execute_result scoped -%}{%- endblock execute_result -%}
  46. {%- elif output.output_type == 'stream' -%}
  47. {%- block stream scoped -%}
  48. {%- if output.name == 'stdout' -%}
  49. {%- block stream_stdout scoped -%}
  50. {%- endblock stream_stdout -%}
  51. {%- elif output.name == 'stderr' -%}
  52. {%- block stream_stderr scoped -%}
  53. {%- endblock stream_stderr -%}
  54. {%- elif output.name == 'stdin' -%}
  55. {%- block stream_stdin scoped -%}
  56. {%- endblock stream_stdin -%}
  57. {%- endif -%}
  58. {%- endblock stream -%}
  59. {%- elif output.output_type == 'display_data' -%}
  60. {%- block display_data scoped -%}
  61. {%- block data_priority scoped -%}
  62. {%- endblock data_priority -%}
  63. {%- endblock display_data -%}
  64. {%- elif output.output_type == 'error' -%}
  65. {%- block error scoped -%}
  66. {%- for line in output.traceback -%}
  67. {%- block traceback_line scoped -%}{%- endblock traceback_line -%}
  68. {%- endfor -%}
  69. {%- endblock error -%}
  70. {%- endif -%}
  71. {%- endblock output -%}
  72. {%- endfor -%}
  73. {%- endblock outputs -%}
  74. {%- endblock output_group -%}
  75. {%- endif -%}
  76. {%- endblock codecell -%}
  77. {%- endif -%}
  78. {%- elif cell.cell_type in ['markdown'] -%}
  79. {%- if resources.global_content_filter.include_markdown and not cell.metadata.get("transient",{}).get("remove_source", false) -%}
  80. {%- block markdowncell scoped-%} {%- endblock markdowncell -%}
  81. {%- endif -%}
  82. {%- elif cell.cell_type in ['raw'] -%}
  83. {%- if resources.global_content_filter.include_raw and not cell.metadata.get("transient",{}).get("remove_source", false) -%}
  84. {%- block rawcell scoped -%}
  85. {%- if cell.metadata.get('raw_mimetype', '').lower() in resources.get('raw_mimetypes', ['']) -%}
  86. {{ cell.source }}
  87. {%- endif -%}
  88. {%- endblock rawcell -%}
  89. {%- endif -%}
  90. {%- else -%}
  91. {%- if resources.global_content_filter.include_unknown and not cell.metadata.get("transient",{}).get("remove_source", false) -%}
  92. {%- block unknowncell scoped-%}
  93. {%- endblock unknowncell -%}
  94. {%- endif -%}
  95. {%- endif -%}
  96. {%- endblock any_cell -%}
  97. {%- endfor -%}
  98. {%- endblock body_loop -%}
  99. {%- block body_footer -%}
  100. {%- endblock body_footer -%}
  101. {%- endblock body -%}
  102. {%- block footer -%}
  103. {%- endblock footer -%}