Macros

Wiki on a Stick (version 0.10.7 and above) supports wiki macros for pluggable wiki syntax.

Definition

A macro block is defined as follows:

<<< ... the macro content here ... >>>

However the above macro example is not parsed in any particular way by WoaS. If you want to run a plugged-in parser on the macro content you should use this syntax instead:

<<<macroname: 24 56 89 28 19 33 >>>


Real example

For example, let's define the sum macro:

<<<%my_sum: var elements = macro.text.split(/[\s\n]+/), total = 0; for (var i=0,l=elements.length;i<l;++i) { if (!elements[i].length) continue; try { total += parseInt(elements[i]); } catch(e) { } } macro.text = total.toString(); >>>


Note that macro definition happens with the special '%' sign before the macro name. Macros cannot be overriden with the macro definition.
Such defined macro uses the macro object which has two standard properties:Now we call the macro:

<<<my_sum: 24 56 89 28 19 33 >>>


And this is the actual result:
249