[Piglit] [PATCH 3/7] Move functions out of index.mako and into functions.mako
Dylan Baker
baker.dylan.c at gmail.com
Thu Oct 17 15:09:39 CEST 2013
Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
---
templates/functions.mako | 61 ++++++++++++++++++++++++++++++++++++++++++++++++
templates/index.mako | 54 ++++++------------------------------------
2 files changed, 68 insertions(+), 47 deletions(-)
create mode 100644 templates/functions.mako
diff --git a/templates/functions.mako b/templates/functions.mako
new file mode 100644
index 0000000..7e14274
--- /dev/null
+++ b/templates/functions.mako
@@ -0,0 +1,61 @@
+## Copyright (c) 2013 Intel Corporation
+##
+## Permission is hereby granted, free of charge, to any person obtaining a
+## copy of this software and associated documentation files (the "Software"),
+## to deal in the Software without restriction, including without limitation
+## the rights to use, copy, modify, merge, publish, distribute, sublicense,
+## and/or sell copies of the Software, and to permit persons to whom the
+## Software is furnished to do so, subject to the following conditions:
+##
+## The above copyright notice and this permission notice (including the next
+## paragraph) shall be included in all copies or substantial portions of the
+## Software.
+##
+## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+### THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+## FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+## IN THE SOFTWARE.
+
+<%def name="new_row()">
+ <tr>
+</%def>
+
+<%def name="end_row()">
+ </tr>
+</%def>
+
+<%def name="group_row(hclass, indent, text)">
+ <td>
+ <div class="${hclass}" style="margin-left: ${indent}em">
+ <b>${text}</b>
+ </div>
+ </td>
+</%def>
+
+<%def name="test_row(hclass, indent, text)">
+ <td>
+ <div class="${hclass}" style="margin-left: ${indent}em">
+ ${text}
+ </div>
+ </td>
+</%def>
+
+<%def name="group_result(hclass, text)">
+ <td class="${hclass}">
+ <b>${text}</b>
+ </td>
+</%def>
+
+<%def name="test_result(hclass, href, text)">
+ <td class="${hclass}">
+ ## If the result is in the excluded results page list from
+ ## argparse, just print the text, otherwise add the link
+ % if hclass not in exclude:
+ <a href="${href}">${text}</a>
+ % else:
+ ${text}
+ % endif
+</%def>
diff --git a/templates/index.mako b/templates/index.mako
index fec9672..5833718 100644
--- a/templates/index.mako
+++ b/templates/index.mako
@@ -1,44 +1,4 @@
-<%def name="new_row()">
- <tr>
-</%def>
-
-<%def name="end_row()">
- </tr>
-</%def>
-
-<%def name="group_row(hclass, indent, text)">
- <td>
- <div class="${hclass}" style="margin-left: ${indent}em">
- <b>${text}</b>
- </div>
- </td>
-</%def>
-
-<%def name="test_row(hclass, indent, text)">
- <td>
- <div class="${hclass}" style="margin-left: ${indent}em">
- ${text}
- </div>
- </td>
-</%def>
-
-<%def name="group_result(hclass, text)">
- <td class="${hclass}">
- <b>${text}</b>
- </td>
-</%def>
-
-<%def name="test_result(hclass, href, text)">
- <td class="${hclass}">
- ## If the result is in the excluded results page list from
- ## argparse, just print the text, otherwise add the link
- % if hclass not in exclude:
- <a href="${href}">${text}</a>
- % else:
- ${text}
- % endif
-</%def>
-
+<%namespace name="functions" file="functions.mako" />
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
@@ -78,17 +38,17 @@
</colgroup>
% for line in results:
% if line['type'] == "newRow":
- ${new_row()}
+ ${functions.new_row()}
% elif line['type'] == "endRow":
- ${end_row()}
+ ${functions.end_row()}
% elif line['type'] == "groupRow":
- ${group_row(line['class'], line['indent'], line['text'])}
+ ${functions.group_row(line['class'], line['indent'], line['text'])}
% elif line['type'] == "testRow":
- ${test_row(line['class'], line['indent'], line['text'])}
+ ${functions.test_row(line['class'], line['indent'], line['text'])}
% elif line['type'] == "groupResult":
- ${group_result(line['class'], line['text'])}
+ ${functions.group_result(line['class'], line['text'])}
% elif line['type'] == "testResult":
- ${test_result(line['class'], line['href'], line['text'])}
+ ${functions.test_result(line['class'], line['href'], line['text'])}
% elif line['type'] == "other":
${line['text']}
% endif
--
1.8.1.5
More information about the Piglit
mailing list