From 7b5fa81e31a759e795fe4ab5c7c78c11c3429d4e Mon Sep 17 00:00:00 2001 From: Ferry Boender Date: Tue, 31 Mar 2015 22:37:17 +0200 Subject: [PATCH] Move inline HTML templates to top. --- src/scriptform.py | 74 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 24 deletions(-) diff --git a/src/scriptform.py b/src/scriptform.py index 1e39289..b01c400 100755 --- a/src/scriptform.py +++ b/src/scriptform.py @@ -89,6 +89,50 @@ html_footer = ''' ''' +html_list = ''' +{header} +
+ {form_list} +
+{footer} +''' + +html_form = ''' +{header} +
+

{title}

+

{description}

+
+ +
    + {fields} +
  • +
+
+
+{footer} +''' + +html_submit_response = ''' +{header} +
+

{title}

+

Result

+
{msg}
+ +
+{footer} +''' + class FormDefinition: """ @@ -323,15 +367,11 @@ class ScriptFormWebApp(WebAppHandler): name=form_name) ) - output = ''' - {header} -
- {form_list} -
- {footer} - '''.format(header=html_header.format(title=self.scriptform.title), - footer=html_footer, - form_list=''.join(h_form_list)) + output = html_list.format( + header=html_header.format(title=self.scriptform.title), + footer=html_footer, + form_list=''.join(h_form_list) + ) self.send_response(200) self.send_header('Content-type', 'text/html') #self.send_header('Expires', 'Mon, 30 Mar 2015 16:00:00 GMT') @@ -409,21 +449,7 @@ class ScriptFormWebApp(WebAppHandler): self.username not in form_def.allowed_users: raise Exception("Not authorized") - output = ''' - {header} -
-

{title}

-

{description}

-
- -
    - {fields} -
  • -
-
-
- {footer} - '''.format( + output = html_form.format( header=html_header.format(title=self.scriptform.title), footer=html_footer, title=form_def.title,