Tags:
create new tag
, view all tags

Parameterized Includes

2008-06-08 - 23:07:02 by RichMorin in Usability
I have recently been creating a number of TWiki pages that contain multiple variations on very similar code; e.g., many twisties like this one:

%TWISTY{mode="div"
  showlink="<tt>schema_info</tt>"
  hidelink="<tt>schema_info</tt>"
  showimgleft="%ICONURLPATH{toggleopen-small}%"
  hideimgleft="%ICONURLPATH{toggleclose-small}%"
}%

where the only difference is the showlink/hidelink text.

As a programmer, I don't like to repeat code. I prefer to write a function, use a macro, or set a variable. (Don't Repeat Yourself).

I asked the TWiki Community for suggestions in GenericMacroProcessing and Peter Thoeny suggested ParameterizedIncludes.

Parameterized Includes are just the thing! I've defined several at the top level of my Project web:

and am using them a zillion times on pages such as:

Once again, TWiki has what I need!

Comments

 

Topic revision: r7 - 2008-09-01 - RichMorin
 

Twitter Delicious Facebook Digg Google Bookmarks E-mail LinkedIn Reddit StumbleUpon    
  • Download TWiki
TWiki logo Powered by PerlIdeas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.