summaryrefslogtreecommitdiff
path: root/tablib/formats/_html.py
diff options
context:
space:
mode:
Diffstat (limited to 'tablib/formats/_html.py')
-rw-r--r--tablib/formats/_html.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/tablib/formats/_html.py b/tablib/formats/_html.py
new file mode 100644
index 0000000..c68eb37
--- /dev/null
+++ b/tablib/formats/_html.py
@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+
+""" Tablib - HTML export support.
+"""
+
+import cStringIO
+
+import markup
+import tablib
+
+title = 'html'
+extentions = ('html', )
+
+def export_set(dataset):
+
+ """HTML representation of a Dataset."""
+
+ stream = cStringIO.StringIO()
+
+ page = markup.page()
+ page.table.open()
+
+ if dataset.headers is not None:
+ page.thead.open()
+ headers = markup.oneliner.th(dataset.headers)
+ page.tr(headers)
+ page.thead.close()
+
+ for row in dataset:
+ html_row = markup.oneliner.td(row)
+ page.tr(html_row)
+
+ page.table.close()
+
+ stream.writelines(str(page))
+
+ return stream.getvalue()
+