strip jinja empty lines

reduce number of empty html lines in rendered pages
This commit is contained in:
Victor Feyens 2021-04-28 17:16:41 +02:00
parent f676f4c754
commit 171288b200
4 changed files with 71 additions and 72 deletions

View File

@ -1,19 +1,19 @@
{% extends "basic/layout.html" %} {%- extends "basic/layout.html" %}
{% set html5_doctype = True %} {%- set html5_doctype = True %}
{% block css %} {%- block css %}
{{ super() }} {{ super() }}
{% if 'custom-css' in meta %}{# Allow custom css style import for specific pages #} {%- if 'custom-css' in meta %}{# Allow custom css style import for specific pages #}
{% set css_files = meta['custom-css'].split(',') %} {%- set css_files = meta['custom-css'].split(',') %}
{% for css_file in css_files %} {%- for css_file in css_files %}
{% set link = '_static/css/' + css_file %} {%- set link = '_static/css/' + css_file %}
<link rel="stylesheet" href="{{ pathto(link, 1) }}" type="text/css"/> <link rel="stylesheet" href="{{ pathto(link, 1) }}" type="text/css"/>
{% endfor %} {%- endfor %}
{% endif %} {%- endif %}
{% endblock %} {%- endblock %}
{% block scripts %} {%- block scripts %}
{% if 'custom-js' in meta %}{# Allow custom js import for specific pages #} {%- if 'custom-js' in meta %}{# Allow custom js import for specific pages #}
{# Before the custom files using React & Immutable (accounting mementos) #} {# Before the custom files using React & Immutable (accounting mementos) #}
<script src="https://cdnjs.cloudflare.com/ajax/libs/immutable/3.8.2/immutable.min.js" <script src="https://cdnjs.cloudflare.com/ajax/libs/immutable/3.8.2/immutable.min.js"
integrity="sha512-myCdDiGJRYrvRb/VuJ67ljifYTJdc1jdEvL4c4ftX9o3N6EAnmD83c/7l2/91RCINZ7c8w21tiXDT7RDFjdc3g==" integrity="sha512-myCdDiGJRYrvRb/VuJ67ljifYTJdc1jdEvL4c4ftX9o3N6EAnmD83c/7l2/91RCINZ7c8w21tiXDT7RDFjdc3g=="
@ -22,102 +22,101 @@
integrity="sha512-wsnDgOxfyn4lhblRMHPMuJh+9CnLcwcisda1zLRGNWKh6OiQynebYTyRZYgH+eWLEdNTKak0OD2GAd/S51UhTw==" integrity="sha512-wsnDgOxfyn4lhblRMHPMuJh+9CnLcwcisda1zLRGNWKh6OiQynebYTyRZYgH+eWLEdNTKak0OD2GAd/S51UhTw=="
crossorigin="anonymous"></script> crossorigin="anonymous"></script>
<script src="{{ pathto('_static/js/atom.js', 1) }}"></script> <script src="{{ pathto('_static/js/atom.js', 1) }}"></script>
{% set js_files = meta['custom-js'].split(',') %} {%- set js_files = meta['custom-js'].split(',') %}
{% for js_file in js_files %} {%- for js_file in js_files %}
{% set link = '_static/js/' + js_file %} {%- set link = '_static/js/' + js_file %}
<script src="{{ pathto(link, 1) }}"></script> <script src="{{ pathto(link, 1) }}"></script>
{% endfor %} {%- endfor %}
{% endif %} {%- endif %}
{{ super() }} {# Load the scripts specified in the extensions/themes #} {{ super() }} {# Load the scripts specified in the extensions/themes #}
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.bundle.min.js" <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.bundle.min.js"
integrity="sha384-b5kHyXgcpbZJO/tY9Ul7kGkf1S0CWuKcCD38l8YkeH8z8QjE0GmW1gYU5S9FOnJ0" integrity="sha384-b5kHyXgcpbZJO/tY9Ul7kGkf1S0CWuKcCD38l8YkeH8z8QjE0GmW1gYU5S9FOnJ0"
crossorigin="anonymous"></script> crossorigin="anonymous"></script>
{% endblock %} {%- endblock %}
{% block linktags %} {%- block linktags %}
{% for alternate_language, language_code, url in alternate_languages %} {%- for alternate_language, language_code, url in alternate_languages %}
<link rel="alternate" hreflang="{{ language_code }}" href="{{ url }}" /> <link rel="alternate" hreflang="{{ language_code }}" href="{{ url }}" />
{%- endfor %} {%- endfor %}
<link rel="canonical" href="{{ canonical }}" /> <link rel="canonical" href="{{ canonical }}" />
{{ super() }} {{ super() }}
{% endblock %} {%- endblock %}
{# {#
Google analytics key logic. Google analytics key logic.
We do not want to call super here since our custom footer logic is defined in the content block. We do not want to call super here since our custom footer logic is defined in the content block.
#} #}
{% block footer %} {%- block footer %}
{%- if google_analytics_key -%} {%- if google_analytics_key -%}
{% include "layout_templates/google_analytics.html" %} {%- include "layout_templates/google_analytics.html" %}
{%- endif -%} {%- endif -%}
{% endblock %} {%- endblock %}
{% block header %} {%- block header %}
<noscript> <noscript>
<nav class="o_side_nav border-end"> <nav class="o_side_nav border-end">
{% include "layout_templates/menu.html" %} {%- include "layout_templates/menu.html" %}
</nav> </nav>
</noscript> </noscript>
{# shown when js has properly set all the classes on the toc elements #} {# shown when js has properly set all the classes on the toc elements #}
<nav id="o_main_toctree" class="o_side_nav border-end" hidden> <nav id="o_main_toctree" class="o_side_nav border-end" hidden>
{% include "layout_templates/menu.html" %} {%- include "layout_templates/menu.html" %}
</nav> </nav>
<header class="o_main_header border-bottom navbar navbar-light navbar-expand-lg"> <header class="o_main_header border-bottom navbar navbar-light navbar-expand-lg">
{% include "layout_templates/header.html" %} {%- include "layout_templates/header.html" %}
<button class="navbar-toggler pe-3 border-0" type="button" data-bs-toggle="collapse" data-bs-target="#o_main_toctree" aria-label="Toggle navigation"> <button class="navbar-toggler pe-3 border-0" type="button" data-bs-toggle="collapse" data-bs-target="#o_main_toctree" aria-label="Toggle navigation">
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
</button> </button>
</header> </header>
{% endblock %} {%- endblock %}
{% block content %} {%- block content %}
<div id="wrap"> <div id="wrap">
{% set main_classes = [] %} {%- set main_classes = [] %}
{% if pagename == master_doc %} {# The current page is the homepage #} {%- if pagename == master_doc %} {# The current page is the homepage #}
{% set main_classes = main_classes + ['index'] %} {# TODO EDI should be 'o_index' #} {%- set main_classes = main_classes + ['index'] %} {# TODO EDI should be 'o_index' #}
{% endif %} {%- endif %}
{% if 'code-column' in meta %} {# The page contains a 'memento' (dynamic side block) #} {%- if 'code-column' in meta %} {# The page contains a 'memento' (dynamic side block) #}
{% set main_classes = main_classes + ['o_has_code_column'] %} {%- set main_classes = main_classes + ['o_has_code_column'] %}
{% endif %} {%- endif %}
{% if 'classes' in meta %} {# The page source defines custom classes #} {%- if 'classes' in meta %} {# The page source defines custom classes #}
{% set main_classes = main_classes + meta['classes'].split() %} {%- set main_classes = main_classes + meta['classes'].split() %}
{% endif %} {%- endif %}
{% if 'hide-page-toc' in meta %} {%- if 'hide-page-toc' in meta %}
{% set main_classes = main_classes + ['o_fullwidth_page'] %} {%- set main_classes = main_classes + ['o_fullwidth_page'] %}
{% endif %} {%- endif %}
<div class="px-3 py-4 d-lg-none"> <div class="px-3 py-4 d-lg-none">
<!-- Searchbox only visible in mobile --> <!-- Searchbox only visible in mobile -->
{% include "layout_templates/searchbox.html" %} {%- include "layout_templates/searchbox.html" %}
</div> </div>
<main class="container-fluid {{ ' '.join(main_classes) }}"> <main class="container-fluid {{ ' '.join(main_classes) }}">
{% if pagename == master_doc %} {%- if pagename == master_doc %}
{# Custom landing page on the root of the documentation #} {# Custom landing page on the root of the documentation #}
{% include "layout_templates/homepage.html" %} {%- include "layout_templates/homepage.html" %}
{% else %} {%- else %}
<article id="o_content" class="doc-body"> <article id="o_content" class="doc-body">
<div role="main">{# Beacon used by the Sphinx search to know where to look for a string #} <div role="main">{# Beacon used by the Sphinx search to know where to look for a string #}
{% block body %} {% endblock %} {%- block body %} {%- endblock %}
</div> </div>
{% if github_link and pagename != 'search' %} {%- if github_link and pagename != 'search' %}
<a href="{{ github_link(mode='edit') }}" class="o_git_link d-none d-lg-inline-block"><i class="i-edit"></i> Edit on GitHub</a> <a href="{{ github_link(mode='edit') }}" class="o_git_link d-none d-lg-inline-block"><i class="i-edit"></i> Edit on GitHub</a>
{% endif %} {%- endif %}
</article> </article>
{% endif %} {%- endif %}
</main> </main>
{# VFE TODO Check if this condition is still needed ??? #} {%- if 'hide-page-toc' not in meta %}
{% if pagename not in toc and 'hide-page-toc' not in meta %}
<aside id="o_page_toc" class="o_page_toc"> <aside id="o_page_toc" class="o_page_toc">
{% include "layout_templates/page_toc.html" %} {%- include "layout_templates/page_toc.html" %}
</aside> </aside>
{% endif %} {%- endif %}
</div> </div>
<footer> <footer>
{% include "layout_templates/footer.html" %} {%- include "layout_templates/footer.html" %}
</footer> </footer>
{% endblock %} {%- endblock %}

View File

@ -4,9 +4,9 @@
<span>docs</span> <span>docs</span>
</a> </a>
</div> </div>
{% include "layout_templates/searchbox.html" %} {%- include "layout_templates/searchbox.html" %}
<div class="d-none d-lg-flex"> <div class="d-none d-lg-flex">
{% include "layout_templates/language_switcher.html" %} {%- include "layout_templates/language_switcher.html" %}
{% include "layout_templates/version_switcher.html" %} {%- include "layout_templates/version_switcher.html" %}
<a class="btn btn-primary fw_semibold" href="https://odoo.com/trial">Try Odoo for FREE</a> <a class="btn btn-primary fw_semibold" href="https://odoo.com/trial">Try Odoo for FREE</a>
</div> </div>

View File

@ -1,22 +1,22 @@
<div class="o_languages me-3"> <div class="o_languages me-3">
<div class="dropdown"> <div class="dropdown">
{% if alternate_languages|length > 0 %} {%- if alternate_languages|length > 0 %}
<button class="btn border dropdown-toggle" <button class="btn border dropdown-toggle"
id="languages" id="languages"
data-bs-toggle="dropdown"> data-bs-toggle="dropdown">
{{ language }} {# The current language #} {{ language }} {# The current language #}
</button> </button>
{% else %} {%- else %}
<button class="btn border" <button class="btn border"
id="languages" id="languages"
disabled=""> disabled="">
{{ language }} {# The current language #} {{ language }} {# The current language #}
</button> </button>
{% endif %} {%- endif %}
<ul class="dropdown-menu" aria-labelledby="languages"> <ul class="dropdown-menu" aria-labelledby="languages">
{% for alternate_language, language_code, url in alternate_languages %} {%- for alternate_language, language_code, url in alternate_languages %}
<li><a class="dropdown-item" href="{{ url }}">{{ alternate_language }}</a></li> <li><a class="dropdown-item" href="{{ url }}">{{ alternate_language }}</a></li>
{% endfor %} {%- endfor %}
</ul> </ul>
</div> </div>
</div> </div>

View File

@ -4,23 +4,23 @@
</div> </div>
<div class="col"> <div class="col">
<div class="dropdown"> <div class="dropdown">
{% if alternate_versions|length > 0 %} {%- if alternate_versions|length > 0 %}
<button class="btn border dropdown-toggle" <button class="btn border dropdown-toggle"
id="versions" id="versions"
data-bs-toggle="dropdown"> data-bs-toggle="dropdown">
{{ version }} {# The current version #} {{ version }} {# The current version #}
</button> </button>
{% else %} {%- else %}
<button class="btn border" <button class="btn border"
id="versions" id="versions"
disabled=""> disabled="">
{{ version }} {# The current version #} {{ version }} {# The current version #}
</button> </button>
{% endif %} {%- endif %}
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="versions"> <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="versions">
{% for alternate_version, url in alternate_versions %} {%- for alternate_version, url in alternate_versions %}
<li><a class="dropdown-item" href="{{ url }}">{{ alternate_version }}</a></li> <li><a class="dropdown-item" href="{{ url }}">{{ alternate_version }}</a></li>
{% endfor %} {%- endfor %}
</ul> </ul>
</div> </div>
</div> </div>