17 - Consistent Tool Arguments
nav_first.pngFirst: design:1
1 - Rate Module
Edited: 29 Apr 2012 00:01 by: GoVegan
Comments: 21
Tags:
nav_prev.pngPrevious: design:16
16 - Standard List Processing
Edited: 11 Nov 2009 15:42 by: Steven Heynderickx
Comments: 0
Tags:
Last: design:32
32 - Parenthood Module
Edited: 11 Nov 2009 21:47 by: Steven Heynderickx
Comments: 7
Tags:
nav_last.png
Next: design:18
18 - Data Forms
Edited: 11 Nov 2009 15:47 by: Steven Heynderickx
Comments: 23
Tags:
nav_next.png

17 - Consistent Tool Arguments
Created on 27 Sep 2009 12:06
By pieterh

rating: +2+x
This is the Redirect module that redirects the browser directly to the "http://projects.wikidot.com/thread:125" page.

Wikidot uses (due to historical merging of various ideas) inconsistent syntax for passing arguments to tools (modules and tools like include, image, etc.). There are at least three syntaxes for passing arguments: unnamed (e.g. [[image filename]]), named without delimiters (e.g. [[include filename argument = value | argument = value]]) and named with delimiters (e.g. [[module ListPages category="*"]]).

As well as being inconsistent, argument values are limited in important ways: they cannot contain special characters like quotes, they cannot run over multiple lines, etc.

The goal of this design sketch is to define a single consistent syntax for arguments that can be used in new tools. It works as follows:

  • It uses the named argument style (name = "value")
  • It provides a mechanism for escaping special characters
  • It provides a mechanism for creating multiline (block) values

Escaping special characters

The character "\" is used to escape single characters inside the string value. To pass the backslash, we use two backslashes. All characters can be escaped.

Passing a block value

To pass a block value the tool must use closures, i.e. a closing tag that matches the opening tag. Between the opening and closing tag, we have a body that may provide templating for tools like ListPages.

We pass a block value within the tool body as follows:

[[opening tag]]
==== name
value
====
[[closing tag]]

The closing marker '====' is optional when the block ends with another value, or at the closing tag. Here is an example of ListPages using this style (and the new header/footer arguments defined in design:12:

[[module ListPages]]
==== header
[[table style="border: 1px solid #000"]]
==== footer
[[/table]]
[[/module]]

Comments: 0

Add a New Comment