Tags:
create new tag
view all tags

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

TWiki version: TWikiRelease04x00x04
TWiki plugins: SpreadSheetPlugin CommentPlugin PreferencesPlugin TablePlugin
Server OS: Debian GNU/Linux
Web server: Apache
Perl version:  
Client OS:  
Web Browser:  
Categories: Missing functionality

-- DenisHowe - 21 Jul 2006

Answer

ALERT! 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

Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r6 - 2006-09-01 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.