wiki:WikiMacros

Version 2 (modified by anonymous, 19 years ago) (diff)

--

order adipex online adipex price cvs online pharmacy canada discount online pharmacy valium buying online valium half life buy xenical uk xenical diet personal loan after bankruptcy low rate personal loan buy xanax online purchase xanax cheap buy xanax online order xanax online cheap propecia buy propecia online generic zoloft zoloft headache meridia weight loss pill cheapest meridia buy phentermine buy phentermine purchase alprazolam online alprazolam 1mg apo clonazepam anxiety ic clonazepam info cialis on line cialis versus viagra order clonazepam online buy clonazepam online buy celexa online celexa phentermine picture zyban stop smoking zyban prozac weight loss prozac weight gain order ambien online buy ambien online zyban prices how to use zyban buy zoloft zoloft weight gain purchase cheap carisoprodol order carisoprodol online xanax and grapefruit xanax pill shortage of tamiflu tamiflu and manufacturer buy phendimatrazine phendimetrazine buy florida in phendimetrazine buy phentermine lowest price phentermine information on carisoprodol sale buying carisoprodol tablet drug meridia canada meridia free health insurance quote health insurance lead authorized rolex dealer new rolex watch online adipex discount cheap adipex online dose lexapro lexapro review didrex cod shipping order didrex online celexa wellbutrin celexa manufacturer information lexapro tablet generic lexapro medication mylan valium buy valium online carisoprodol online soma soma muscle healthy weight loss weight loss drug levitra prescription free levitra on line discount prozac christina ricci prozac nation pic swiss rolex replica fake rolex watch cheap propecia generic propecia online xenical diet pill low cost xenical unsecured personal loan bad credit personal loan order levitra online levitra prescription buy viagra online buy viagra online picture of lorazepam drug generic lorazepam information paxil dosage paxil lawsuit geico car insurance new york car insurance delivery didrex saturday didrex lowest price health insurance houston north carolina health insurance discount nexium bijwerkingen and nexium viagra information viagra sale valium diazepam web.com buy diazepam online discount soma soma compound order prilosec online prilosec coupon free health insurance quote health insurance lead ambien vs lunesta ambien sleep aid viagra erection where to buy viagra ambien online pharmacy ambien generic online bontril coast online west cheap bontril sr buy prilosec online pharmacy prilosec purchase purchase viagra online buy viagra online manufacturer of nexium cost of nexium soma tablet buy cheap soma online phentermine adipex ionamin phentermine diet pill weight loss valium sale mylan valium phendimetrazine tartrate order phendimetrazine online order diazepam online valium diazepam web.com order tamiflu canada tamiflu avian flu buy alprazolam online alprazolam buy viagra in uk natural viagra buy viagra buy viagra rolex explorer rolex watch for sale car insurance washington dc on line car insurance quote purchase xanax cheap order xanax online ativan lorazepam lorazepam Watson online canadian online discount pharmacy online internet pharmacy order lorazepam online buy lorazepam online online pharmacy medicine canada online pharmacy buy viagra online buy viagra online cialis tablet cialis uprima viagra alprazolam prescription alprazolam picture buy cheapest phentermine order phentermine online health weight loss diet green tea weight loss klonopin vs xanax pill drug klonopin wafer carisoprodol medication cheap carisoprodol online geico car insurance new york car insurance ambien buy cheap cheap ambien cialis for woman cialis on line buy phentermine online cheap phentermine order adipex online order adipex online free viagra sample viagra sample no credit check personal loan uk unsecured personal loan apo diazepam 5mg cheap diazepam 10mg buy bontril online weight loss recipe la weight loss paxil ocd paxil for social anxiety

Wiki Macros

Trac macros are plugins to extend the Trac engine with custom 'functions' written in Python. A macro inserts dynamic HTML data in any context supporting WikiFormatting.

Another kind of macros are WikiProcessors. They typically deal with alternate markup formats and representation of larger blocks of information (like source code highlighting). See also: WikiProcessors.

Using Macros

Macro calls are enclosed in two square brackets. Like python functions, macros can also have arguments, a comma separated list within parenthesis.

Examples

 [[Timestamp]]

Display:

Timestamp?

 [[HelloWorld(Testing)]]

Display:

HelloWorld(Testing)?

Available Macros

Macros are still a new feature, and the list of available (and distributed) macros is admittedly not very impressive. In future Trac releases, we hope to build a library of useful macros, and will of course happily include contributed macros (see below).

  • HelloWorld -- An example macro, useful for learning how to write macros.
  • Timestamp -- Insert the current date and time.

Macros from around the world

The Trac Project has a section dedicated to user-contributed macros, MacroBazaar. If you're looking for new macros, or have written new ones to share with the world, don't hesitate adding it to the MacroBazaar wiki page.

http://projects.edgewall.com/trac/wiki/MacroBazaar


Developing New Macros

Macros, like Trac itself, are written in the Python programming language. They are very simple modules, identified by the filename and should contain a single entry point function. Trac will display the returned data inserted into the HTML where the macro was called.

It's easiest to learn from an example:

# MyMacro.py -- The world's simplest macro

def execute(hdf, args, env):
    return "Hello World called with args: %s" % args

Advanced Topics: Template-enabled Macros

For advanced uses, macros can also render structured output in HDF, to be rendered to HTML using clearsilver templates - like most Trac output. In short, this allows more generic and well-designed advanced macros.

Macros gain direct access to the main HDF tree, and are free to manipulate it.

Example:

def execute(hdf, args, env):
    # Currently hdf is set only when the macro is called
    # From a wiki page
    if hdf:
        hdf.setValue('wiki.macro.greeting', 'Hello World')
        
    # args will be null if the macro is called without parentesis.
    args = args or 'No arguments'
    return 'Hello World, args = ' + args

You can also use the environment (env) object to access configuration data.

Example.

def execute(hdf, txt, env):
    return env.get_config('trac', 'repository_dir')

See also: WikiProcessors, WikiFormatting, TracGuide