{% macro header_links(links) -%} {% for link in links %} {% endfor %} {%- endmacro %} {% macro scripts(input_scripts) -%} {% for script in input_scripts %} {% endfor %} {%- endmacro %} {% macro complete_index_page(relative_head_links, relative_body_scripts, central_head_links=None, central_body_scripts=None) -%} Flame {% if central_head_links %} {# If there is a central sever, try to load resources from there to leverage browser caching #} {{ header_links(central_head_links) }} {# If the main app couldn't be loaded from the central server, load the relative files. This involves recursively re-creating this entire index page with only the relative links/scripts #} {% else %} {# If no central server, exclusively serve the relative files (no fallback) #} {# This can mean either the entire flame server has no central server from which to fetch the UI, or it's the fallback page that is used when a browser fails to load resources from the central server. #} {{ header_links(relative_head_links) }} {% endif %}
{% if central_body_scripts %} {{ scripts(central_body_scripts) }} {% else %} {{ scripts(relative_body_scripts) }} {% endif %} {%- endmacro %} {# The top-level page can be either relative URLs only, or both relative & central (i.e. central with fallback to relative) #} {{ complete_index_page(relative_head_links, relative_body_scripts, central_head_links, central_body_scripts) }}