Help:Macros

From GMATClub

Jump to: navigation, search


{{#x:sidebar| Help: technical wiki documentation


index - edit this box }}


This page documents GMAT Club-specific Macro extensions to wiki markup that can be used on this site. If it does not answer your questions, or you suggest adding new or improving the existing Macros, contact the Macros maintainer, User:Tino.

Contents

Rationale

Macros have the same basic purpose as Templates (see Help:Templates). The need for Macros arises when Templates cannot deliver what is required. These are the Template problems that Macros solve:

  • Templates cannot be nested (no Templates in Templates)
  • Template output is restricted for safety reasons
  • Templates do not have access to the GMAT Club database
  • Templates cannot perform computation, except for basic conditionals provided by ParserFunctions (Help:ParserFunctions)

However, because of all the extra power, only the technical administrators of GMAT Club can define new Macros. This is unlike the Templates which can be edited by the public.

Implementation

Macros are implemented as the x Parser Function [1]. A plain macro with no arguments is called by the following code, where macro-name is replaced by the name of the macro:

 {{#x:macro-name}}

When macros take arguments, the syntax is similar to Template arguments:

 {{#x:macro-name | Argument 1 | Argument 2 | Name = Argument Named 'Name' }}

Reference

Here is a non-exhaustive alphabetical listing of the available Macros.

box

This macro puts what you give it in a box that stands out from the rest of the text. The use of this macro promotes design consistency because when the design changes all the boxes change their appearance simultaneously, without any effort.

   
   {{#x:box|

     ... some content here ...

   }}
  

columns

This macro eases the creation of multi-column layouts. The first argument should be a space-separated list of desired widths (in pixels - 'px', font line heights - 'em', percent of available space - '%', or 'auto' for autodetection), and the rest of the arguments should provide the column contents. Here is an example of an equal-width two-column layout:

 
    {{#x:columns|50% 50%|
        ...
        This is column one (on the left)
        ...
    |
        ...
        This is column two (on the right)
        ...
    }}
  

feedburner

Provided that the Feedburner account is set up correctly, this macro fetches the headlines and article summaries from a given feed and inserts them in a page. The example can be seen on the Main Page where the gmatclub feed is used:

 {{#x:feedburner}}
 

img

This macro simply produces an HTML img tag. For some reason, it has been forbidden in Mediawiki, hence the need for a macro.

 
    {{#x:img|http://example.com/logo.jpg}}
    {{#x:img|http://example.com/logo.jpg|alt=example.com}} - annotate it (''alt'' attribute)
    {{#x:img|http://example.com/logo.jpg|href=http://example.com}} - make it a link    
  

irc

This macro creates a chat box that connects to the specified ICQ IRC Chat channel. The example is of course Chat, which connects to the gmatclub channel:

 {{#x:chat}}

profile

This macro should appear at the top of every page in the User namespace. The basic rationale for using a macro there is that the macro is able to determine the GMAT Club User ID and produce a link to the forum profile of the user, which cannot be done with a Template. However, instead of producing the output itself, the macro actually calls Template:Profile, so the end output is highly customizable by everyone.

 {{#x:profile}}

sidebar

The macro puts its contents into a floating sidebar on the right of the page. The appearance of the sidebar is subject to change as the design is improved. For this reason, it is advisable to use this macro for sidebars, as it is ensures consistency.

 {{#x:sidebar|

     Some long content here...

  }}

to

Sharing email addresses on publicly accessible pages is dangerous because they may be indexed and added to spammers' databases. The to macro solves this problem by producing an image of the email that can be understood by people but not by robots. To be totally protected from robots, do not use the '@' sign, put a space instead, like this:

 {{#x:to|example example.com}}

topkudo

Warning: highly experimental, subject to change. This macro produces a table of users with top Kudos scores, linking their usernames to forum profiles. See People.

 {{#x:topkudo}}

vspace

On plain Mediawiki sites, you can add empty lines to produce vertical space between items. We opted against that on GMAT Club, however, since in many cases you do not want that visual vertical space, but are simply trying to put some empty lines to make the article source more readable. When you do want vertical space, use the vspace macro. The amount can be specified in pixels ('px') or lines ('em'). For example, the following code produces empty vertical space equivalent to 5 lines of text:

 {{#x:vspace|5em}}

You can check how this macro is used in action on the Main Page.

Personal tools
Powered by MediaWiki