wiki:FlatTableMacro

Version 3 (modified by Ashish Kulkarni, 16 years ago) (diff)

--

A Wiki Processor for displaying a table with the markup being entered in a flat form.

Description

This Wiki processor allows you to enter the data for a table in an alternative markup, which is very useful when there are a lot of columns and/or when some of the columns are optional. This markup also has the advantage of being much more readable and diff-friendly, at the expense of requiring more markup.

The column definition for the table has to be specified immediately after the macro directive, eg.

{{{
#!flat-table
#! Name: key, Relation: relation, Comment: comment notes
 [... table data ...]
}}}

Alternatively, one can also create a macro alias via configuration in trac.ini

[flat-table]
dbdoc = Name: key, Relation: relation, Comment: comment notes
dbdoc.description = macro description goes here

For the above example, one can then directly use

{{{
#!dbdoc
 [... table data ...]
}}}

Markup

The markup is loosely based on a very simplified YAML/JSON-like syntax. At least one column is always assumed to be mandatory per table, which is the key column. The order and name of the generated columns is controlled by the metadata line, as shown above. For each column, one can define one or more aliases which can be used in the markup to define the column data.

A line with no leading spaces and ending in a colon defines the start of a new row, with the line content representing the value of the key column. A line with some leading spaces followed by an @alias: defines the column within the row. Any other content on that line or any subsequent lines is assumed to be the content of that column (basic Wiki syntax can be used).

Bugs/Feature Requests

Existing bugs and feature requests for FlatTableMacro are here.

If you have any issues, create a new ticket.

Download

Download the zipped source from [download:flattablemacro here].

Source

You can check out FlatTableMacro from here using Subversion, or browse the source with Trac.

Example

{{{
#!flat-table
#! Name: key, Relation: relation, Comment: comment notes

id:
  @relation: PK

desc:
  @comment: description

other_table_id:
  @relation: FK to other table
  @notes: 
    This is a reference to another table with a [WikiPedia:Wiki wiki] link.
    More than one line can be entered for a column.
}}}

will result in a display like this

Name Relation Comment
id PK
desc description
other_table_id FK to other table This is a reference to another table with a wiki link.
More than one line can be entered for a column.

Recent Changes

18481 by rjollos on 2022-04-10 18:21:04
Make compatible with Python 3

Refs #14134.

18480 by rjollos on 2022-04-10 18:19:38
Fix line endings
16972 by rjollos on 2017-11-18 09:59:43
Add metadata
(more)

Author/Contributors

Author: ashkulz
Contributors: