rolex dealer preowned rolex xenical hgh phentermine quit smoking xenical testimonials hair loss baldness propecia hair loss propecia phentermine on line phentermine adipex ionamin buy viagra online viagra shop 2mg xanax xanax sale buy clonazepam online ic clonazepam info buy rolex submariner man rolex valium buying online generic valium pill order carisoprodol online carisoprodol medication buy phendimetrazine online phendimetrazine overseas best online pharmacy cvs online pharmacy buy prilosec online purchase generic prilosec xanax and grapefruit xanax pill buy cheap soma purchase soma cheap phentermine yellow phentermine on line buy viagra online viagra cialis personal debt consolidation loan cheap personal loan valium diazepam web.com cheapest diazepam buy cialis online buy cheap cialis online auto insurance quote low cost car insurance ambien buying online ambien purchase h5n1 tamiflu buy tamiflu without prescription dosage lexapro drug generic lexapro medication soma cube buy cheap soma zyban online order zyban online bontril saturday delivery bontril pdm low interest personal loan bad credit unsecured personal loan soma muscle soma overnight alprazolam prescription alprazolam 1mg adipex price comparison buy adipex cheap generic lorazepam information ativan sublingual celexa information celexa phentermine car insurance comparison cheap car insurance quote buy phentermine online buy phentermine online generic xenical xenical uk united health care insurance north carolina health insurance ativan dosage ativan information purchase tamiflu online order tamiflu canada lexapro vs prozac prozac benefit use meridia hillcrest how does meridia work buy prilosec online cheap prilosec online buy meridia online buy cheap meridia paxil lawsuit paxil and wellbutrin swiss rolex replica rolex tudor weight loss patch weight loss tip buy viagra viagra online celexa anxiety buy celexa online didrex diet pill didrex cod shipping cost of nexium information on nexium viagra sale online viagra shop buy zyban online order zyban online xanax dosages phobia xanax depression lexapro ocd 10mg lexapro info ambien medicine ambien information buy carisoprodol cod discount carisoprodol info information on carisoprodol sale purchase cheap carisoprodol free health insurance quote temporary health insurance paxil for depression paxil dosage cheap viagra online viagra prescription phentermine online pharmacy phentermine pill lowest price phentermine order phentermine online phendimetrazine tartrate cheap phendimetrazine 35mg student health insurance texas health insurance alprazolam generic purchase alprazolam online nexium vs prilosec cheap nexium price alprazolam generic cheap alprazolam generic lorazepam information brand name lorazepam free cialis cialis vs viagra apo clonazepam anxiety buy clonazepam online adipex information adipex weight loss buy viagra buying viagra free weight loss program perricone diet weight loss valium diazepam web.com buy diazepam online online pharmacy online pharmacy mexico new york car insurance online car insurance propecia result cheap propecia buy adipex online buy adipex online bipolar and zoloft zoloft medicine 105 bontril sr what does valium look like valium pharmacy buy xanax valium purchase xanax cheap 10mg ambien order ambien online order valium online buy valium online didrex overnight order didrex online online pharmacy mexico online discount pharmacy buy carisoprodol diazepam online soma diazepam medication cialis vs viagra order viagra on line perricone diet weight loss weight loss information christina ricci prozac nation order prozac clonazepam medicine 0.5 mg order clonazepam online fast cash personal loan best personal loan purchase cialis online generic cialis price order ambien zolpidem zolpidem tartrate kaufen levitra dysfunction erectile levitra levitra commercial health levitra sexual viagra lowest viagra price viagra sale online zoloft weight gain generic zoloft

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:

Tue 07 Oct 2008 19:00:58 CEST

 [[HelloWorld(Testing)]]

Display:

Hello World, args = 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