Question
How can I define a new variable that takes parameters that get substituted into the rendered value?
Specifically I want to define shortcuts for our leave calendar like this:
* Set SICK{user} = %GREEN% %user% Sick %ENDCOLOR%
(I just made that syntax up) so I could then say, e.g.
%SICK{DenisHowe}%
Would this be a (new) plugin?
Environment
--
DenisHowe - 21 Jul 2006
Answer
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
Did you have a look on
MacrosPlugin yet? Or you could
UsingSnippets.
--
FranzJosefSilli - 21 Jul 2006
Thanks. Both very interesting but still too much typing (I'm very lazy). The whole point is to shorten the input (and capture the pattern in one place).
Rather than thinking of it as a variable definition, how about a regular-expression rewriting plugin, e.g.
%REPLACE{'SICK \w+', '%GREEN% $1 Sick %ENDCOLOR%'}%
to add a new rewrite rule to the current context (topic, web, TWiki)?
--
DenisHowe - 21 Jul 2006
Hm, nice idea Denis, but isn't
ParameterizedVariables what you're looking for?
--
FranzJosefSilli - 21 Jul 2006
You could use
ParameterizedIncludes, such as
%INCLUDE{ "Sick" name="DenisHowe" }%
But if you want less typing you'd need to write a Plugin.
--
PeterThoeny - 21 Jul 2006