Tags:
development1Add my vote for this tag information_design1Add my vote for this tag create new tag
view all tags

MacrosPlugin

NOTE: This plugin is no longer maintained. Its functionality is now covered by the TWiki core (parameterized includes and parameterized variables) and by the preinstalled SetGetPlugin.

Lets you use parameterised includes in TWiki. This plugin supports tags originally included with the TWiki:Plugins/FormQueryPlugin, but now split out for clarity.

Features

  • Macros defined in topics
  • Topic-scope SET function
  • Strip newlines from macro topics

Syntax Rules

%CALLMACRO{...}%

%CALLMACRO is used to include a macro defined in a topic in the current web immediately, as if it were simply typed in the topic. It is like %INCLUDE% except that parameters can be passed in and expanded in the included text.

A macro is defined by creating a topic that contains the macro body. For example, a topic named MacroMaturity may contain the text:

The science of %science% is %state%
This macro can be included in another topic using %CALLMACRO :
%CALLMACRO{topic=MacroMaturity science="biology" state="mature"}%
%CALLMACRO{topic=MacroMaturity science="nanotechnology" state="in its infancy"}%
With fairly obvious results. Note that standard TWiki variables such as %TOPIC% are expanded with the values of the calling topic and not the macro topic. Macro parameter expansions take precedence over any TWiki variable or %SET value for the same name.

%STRIP

To support the inclusion of macros that don't generate any text (e.g. macros containing only %FORMQUERY and %TABLEFORMAT) then the special tag %STRIP% can be included in the macro text. If this is seen, all newlines will be stripped from the macro before it is included in the calling topic. The %STRIP tag only works in the context of a macro body.

%SET pseudo-tag

%SET is called a pseudo-tag because it doesn't operate the same way as normal twiki tags; it generates no output, and is delimited by end-of line.

%SET is used to set a variable value within the context of the current topic. Variable values which are set remain in force only within the current topic, or until the variable is set to a new value. Note that variable values %SET within a %CALLMACRO are available in the calling topic.

%SET tags must occur at the start of a line (no leading spaces) and are terminated by the end of line. For example,

%SET X = 1000
will set %X% to 1000 for the rest of the topic.

Another difference from standard Set is that the RHS of a %SET is fully evaluated immediately. This means that it is unlike a macro, and more like an assignment expression in a programming language. For example,

%SET X = 1000
%SET Y = 100
%SET Z = %CALC{"%X% / %Y%"}%
will set %Z% to the string 10 and NOT the string "%CALC{"1000 / 100"}%". This is a critically important difference; values that are %SET can be used alongside plugins (such as SpreadSheetPlugin) that are very sensitive to format.

MacrosPlugin Settings

One line description, shown in the TextFormattingRules topic:
  • Set SHORTDESCRIPTION = Supports parameterised includes.

Plugin Installation Instructions

Note: These instructions are for the TWiki maintainer. No changes to your browser are required.
  • Download the ZIP file from the Plugin web (see below). Contents:
    File: Description:
    lib/TWiki/Plugins/MacrosPlugin.pm Main plugin script
    data/TWiki/MacrosPlugin.txt Plugin topic

  • Unzip MacrosPlugin.zip in your twiki installation directory.
  • Optionally, run MacrosPlugin_installer to automatically check and install other TWiki modules that this module depends on. You can also do this step manually.
  • Alternatively, manually make sure the dependencies listed in the table below are resolved. None
  • (Dakar) Visit configure in your TWiki installation, and enable the plugin in the {Plugins} section.

Plugin Info

Plugin Author: TWiki:Main/CrawfordCurrie
Plugin Version: 8224
Change History:  
6173 Item196 updates for MacrosPlugin
5223 Documentation fixes, adding gifs.
5048 Cairo readiness
5002 Initial version
28 June 2004 Initial version, split out from TWiki:Plugins/FormQueryPlugin
Dependencies: None
Perl Version: 5.6
Plugin Home: http://TWiki.org/cgi-bin/view/Plugins/MacrosPlugin
Feedback: http://TWiki.org/cgi-bin/view/Plugins/MacrosPluginDev

Related Topics: TWikiPreferences, TWikiPlugins

Further development

Further development of this code is welcomed. It is recommended that you unpack the distribution into a development directory and use the supplied build file which provides targets to run the test suite, and install and uninstall your development code into a test installation. Please, please, please run, and extend if necessary, the test set!

Developer discussion is in TWiki:Plugins/MacrosPluginDev.

Copyright

This code is based on an original development of Motorola Inc. and is protected by the following copyrights:

  • Copyright © 2002-2003 Motorola. All Rights Reserved.
  • Portions Copyright © 2004 Crawford Currie http://www.c-dot.co.uk

License

As required for the publication of all extensions to TWiki, this software is published under the terms of the GNU General Public License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details, published at http://www.gnu.org/copyleft/gpl.html

-- TWiki:Main/CrawfordCurrie - 13:24:23 28 February 2006

Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatmd5 MacrosPlugin.md5 r3 r2 r1 manage 0.2 K 2008-12-12 - 11:43 SopanShewale checksum file , Uploaded as a part of Release Process
Compressed Zip archivetgz MacrosPlugin.tgz r3 r2 r1 manage 5.3 K 2008-12-12 - 11:43 SopanShewale See MacrosPlugin for details. Untar and run the installer script, Uploaded as a part of Release Process
Compressed Zip archivezip MacrosPlugin.zip r6 r5 r4 r3 r2 manage 6.7 K 2008-12-12 - 11:43 SopanShewale See MacrosPlugin for details. Unzip and run the installer script , Uploaded as a part of Release Process
Unknown file formatext MacrosPlugin_installer r2 r1 manage 3.4 K 2008-12-12 - 11:43 SopanShewale Installer Script, Uploaded as a part of Release Process
Edit | Attach | Watch | Print version | History: r12 < r11 < r10 < r9 < r8 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r12 - 2012-04-19 - 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-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.