Skip to content

Commit

Permalink
[web] Extracted Jinja macros
Browse files Browse the repository at this point in the history
  • Loading branch information
chleh committed Oct 17, 2024
1 parent bc95838 commit 09bdb7f
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions Tests/Data/Notebooks/nbconvert_templates/collapsed.md.j2
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
{% extends 'base/display_priority.j2' %}


{% block in_prompt %}
{% endblock in_prompt %}

{% block output_prompt %}
{%- endblock output_prompt %}

{% block input %}
{% if ('jupyter' in cell.metadata and 'source_hidden' in cell.metadata.jupyter and cell.metadata.jupyter.source_hidden == True) or (cell.source.splitlines() | length > 2) -%}
<details>
<summary>
<code>{{ cell.source.splitlines()[0] | e }}</code>&hellip;
<span class="italic text-gray-700 text-sm">(click to toggle)</span>
</summary>
<div>
{% endif %}
{% macro render_full_jupyter_input(cell) -%}
<div class="jupyter-input">

```
Expand All @@ -28,10 +13,30 @@
```

</div>
{% if ('jupyter' in cell.metadata and 'source_hidden' in cell.metadata.jupyter and cell.metadata.jupyter.source_hidden == True) or (cell.source.splitlines() | length > 2) %}
</div>
{%- endmacro %}

{% macro render_jupyter_input(cell, collapsed) -%}
{% if collapsed -%}
<details>
<summary>
<code>{{ cell.source.splitlines()[0] | e }}</code>&hellip;
<span class="italic text-gray-700 text-sm">(click to toggle)</span>
</summary>
{{ render_full_jupyter_input(cell) }}
</details>
{% else %}
{{ render_full_jupyter_input(cell) }}
{% endif %}
{%- endmacro %}

{% block in_prompt %}
{% endblock in_prompt %}

{% block output_prompt %}
{%- endblock output_prompt %}

{% block input %}
{{ render_jupyter_input(cell, ('jupyter' in cell.metadata and 'source_hidden' in cell.metadata.jupyter and cell.metadata.jupyter.source_hidden == True) or (cell.source.splitlines() | length > 2)) }}
{% endblock input %}

{% block error %}
Expand Down

0 comments on commit 09bdb7f

Please sign in to comment.