Source

moin-2.0 / build / lib / MoinMoin / converter / _table.py

# Copyright: 2010 MoinMoin:ThomasWaldmann
# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.

"""
MoinMoin - table data to DOM conversion support
"""


from __future__ import absolute_import, division

from MoinMoin.util.tree import moin_page

class TableMixin(object):
    """
    Mixin to support building a DOM table.
    """
    def build_dom_table(self, rows, head=None, cls=None):
        """
        Build a DOM table with data from <rows>.
        """
        table = moin_page.table()
        if cls is not None:
            table.attrib[moin_page('class')] = cls
        if head is not None:
            table_head = moin_page.table_header()
            table_row = moin_page.table_row()
            for cell in head:
                table_cell = moin_page.table_cell(children=[cell, ])
                table_row.append(table_cell)
            table_head.append(table_row)
            table.append(table_head)
        table_body = moin_page.table_body()
        for row in rows:
            table_row = moin_page.table_row()
            for cell in row:
                table_cell = moin_page.table_cell(children=[cell, ])
                table_row.append(table_cell)
            table_body.append(table_row)
        table.append(table_body)
        return table
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.