Module: check_mk
Branch: master
Commit: ee71372f09cae99ec404f5e8750c318e4f8b9ec3
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ee71372f09cae9…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Oct 27 15:12:51 2017 +0200
table: Add new helper function to render simple text (escaped)
Change-Id: Iea07fc44a4396700e7ecdc7abfba644d21885c32
---
web/htdocs/table.py | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/web/htdocs/table.py b/web/htdocs/table.py
index ebdfd42..1082814 100644
--- a/web/htdocs/table.py
+++ b/web/htdocs/table.py
@@ -141,6 +141,11 @@ class Table(object):
self.next_args = posargs, kwargs
+ def text_cell(self, *args, **kwargs):
+ kwargs["escape_text"] = True
+ cell(*args, **kwargs)
+
+
def cell(self, *posargs, **kwargs):
self.finish_previous()
self.next_func = self.add_cell
@@ -167,18 +172,24 @@ class Table(object):
self.options["collect_headers"] = False
- def add_cell(self, title="", text="", css=None, help=None,
colspan=None, sortable=True):
- if isinstance(text, HTML):
- text = "%s" % text
- if type(text) != unicode:
- text = str(text)
+ def add_cell(self, title="", text="", css=None, help=None,
colspan=None, sortable=True, escape_text=False):
+ if escape_text:
+ text = html.permissive_attrencode(text)
+ else:
+ if isinstance(text, HTML):
+ text = "%s" % text
+ if type(text) != unicode:
+ text = str(text)
+
htmlcode = text + html.drain()
+
if self.options["collect_headers"] == True:
# small helper to make sorting introducion easier. Cells which contain
# buttons are never sortable
if css and 'buttons' in css and sortable:
sortable = False
self.headers.append((title, css, help, sortable))
+
self.rows[-1][0].append((htmlcode, css, colspan))