wiki:FlatTableMacro

Display a table with the markup from data 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:

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

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

[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 the following:

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

See also: TablePlugin.

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).

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.

Bugs/Feature Requests

Existing bugs and feature requests for FlatTableMacro are here.

If you have any issues, create a new ticket.

defect

2 / 2

enhancement

2 / 2

Download

Download the zipped source from here.

Source

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

Installation

General instructions on installing Trac plugins can be found on the TracPlugins page.

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
Maintainer: Ashish Kulkarni
Contributors:

Last modified 7 years ago Last modified on Jan 17, 2018, 9:16:46 PM