We relaunched the TWiki.org project with an expanded TWiki charter, and we invite you to participate! The TWiki.org Code of Conduct agreement took effect on 27 Oct 2008. We ask existing twiki.org users to opt-in. -- PeterThoeny - 27 Oct 2008
Tags:
create new tag
, view all tags

Parameterized Includes

08 Jun 2008 - 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 - 01 Sep 2008 - 19:18:05 - RichMorin
 
TWIKI.NET
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback