The Onion Box
% # for stylesheet in page_stylesheets:
% for stylesheet in session['stylesheets']:
% end
%# NavBar will not be displayed yet helps to navigate via arrow keys
<%
import os.path
import logging
bL = logging.getLogger('theonionbox')
div_open = False
for section in sections:
if section == '-':
%>
<%
continue
end
if section[0] == '!':
out = ''
if div_open:
out += '<' + '/div>' # written in this way to not confuse the PyCharm IDE
div_open = False
end
if len(section) > 1:
out += '<' + 'div id ="{}">'.format(section[1:])
div_open = True
end
%>
{{!out}}
<%
continue
end
file = 'sections/{0}/{0}.html'.format(section)
if os.path.exists(file):
try:
include(file)
except Exception as exc:
import sys, traceback
exc_type, exc_val, exc_tb = sys.exc_info()
bL.warning("While including '{}' into 'index_page.html':\n{}".format(file, traceback.format_exc()))
end
else:
bL.debug("While including '{0}' into 'index_page.html': '{0}' does not exist!".format(file))
end
end
out = ('<' + '/div>') if div_open else ''
%>
{{!out}}
%# NEVER NEVER shall this part of the code be executed!
% for script in session['scripts']:
% end