Card Macro

Description

This macro allows you to use parametrized includes in pages (similar to the templates used in MediaWiki).

Download

http://dev.axel.pp.ru/moinmoin/card-macro/1.5/Card.py

You may use Darcs to access the development repository (code for MoinMoin 1.5 and 1.3 respectively):

http://dev.axel.pp.ru/moinmoin/card-macro/1.5/ (view Darcs log)

http://dev.axel.pp.ru/moinmoin/card-macro/1.3/ (view Darcs log)

A version for Moin 1.9 is attached to the page. -- UeliSchläpfer, 2011-06-19

Syntax description

First we define a template page with special variables, for example name it CardExamplePage (prefix 'Card' is mandatory for card-templates):

#acl All:read,write,revert
# Sample template for Card macro
Hello, ${ARG0}!
Hello, ${ARG1}!

Then you may insert a macro call like

[[Card(ExamplePage MoinMoin, world)]]

In the resulting page you get:

Hello, MoinMoin!
Hello, world!

You may use positional arguments in the template, they are named ${ARG0}, ${ARG1} and so on. You may also use named variables like ${myvar}. There is one special variable - ${CALLER} (TODO: probably need to change name to CALLER_PAGE), this variable contains the name of page from which you called this macro.

An Example Page with macro definition:

# This is page CardExample with macro definition
This macro called from ${CALLER}

Page with macro call:

# This is page SamplePage
[[Card(Example)]]
...other text

Result:

This macro called from SamplePage
...other text

<!> In the current version of this macro there are no default values for arguments.

Multiple arguments are by default separated with a ',' (this behaviour can be changed, if you define in wikiconfig.py the parameter cardmacro_separator (for example cardmacro_separator = "|"). Spaces after separators are ignored. Look at an example:

[[Card(Sample arg1,this is multiword argument 2, arg3)]]

Real life examples

Stub for draft pages

Template CardDraft:

||<: tableclass="card" bgcolor="#EEEEFF"> attachment:Blank_template.gif ||<: bgcolor="#EEEEFF"> This is draft page, help us with it: [[PageAction(${CALLER}, edit)]] ||

Usage: Card(Draft)

This template used the auxiliary macro PageAction - it is a modified version of an Action macro from MoinMoin: PageAction.py

Screenshot from my wiki (text in Russian):



Template CardComments:

== $ARG0 ==
||<( bgcolor="#FFFF99">''Discuss it:'' '''[[PageAction(${CALLER}/Comments, edit)]]'''||
||<( bgcolor="#EEEEEE"> [[Include(${CALLER}/Comments)]] ||

Usage: [[Card(Comments link header)]]

Example screenshot for: [[Card(Comments Add you comment below)]]



Sites using this macro

English is not my native language, please correct errors in this text. -- AlexanderGrafov 2006-04-14 22:28:48

Spruced up the grammar for you. Nice macro by the way. {OK} -- PiMasta 2007-03-08

Discussion

Caveat: When using this macro, I created a line CategoryBleh within the text that is included via CardBleh, and then put this onto a page via the macro. However, if I then list members of the category I don't see that page listed. If I manually at CategoryBleh to the page without using the CardMacro then it is listed fine. It seems like the Category listing looks at the "raw" page when deciding what's in it's Category, rather than the finished article with the Card included. Is this a bug?

I would prefer , and not | as separator for arguments of a parameterlist. Because all other macros and parsers do use ,. If each parser/macro needs always an other separotor it makes explaining and using much more complicated. If you want to keep | for your pages add , as new default. -- ReimarBauer 2006-04-15 05:49:32

Sorry, but i can't download your Macro. I have a timeout error from my browser. -- penaz

The download link for any of the versions does not work. Does anyone have this Macro? Please update download link.

MoinMoin: MacroMarket/CardMacro (last edited 2011-06-19 19:45:37 by UeliSchläpfer)