Code

Changes between Version 1 and Version 2 of WikiMacros


Ignore:
Timestamp:
08/02/05 10:07:43 (9 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • WikiMacros

    v1 v2  
    11=  Wiki Macros = 
    2 Trac macros are plugins to extend the Trac engine with custom 'functions' written in Python. They allow insertion of custom dynamic HTML data in any module supporting WikiFormatting. 
     2Trac 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. 
    33 
    44Another 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. 
     
    2323 
    2424== Available Macros == 
    25 As of 0.6, macros are still a new feature in Trac, and the list of available (and distributed) macros is  
     25Macros are still a new feature, and the list of available (and distributed) macros is  
    2626admittedly 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).  
    2727 
     
    4949# MyMacro.py -- The world's simplest macro 
    5050 
    51 def execute(hdf, args): 
     51def execute(hdf, args, env): 
    5252    return "Hello World called with args: %s" % args 
    5353}}} 
     
    5959 
    6060Example: 
    61  
    6261{{{ 
    63 def execute(hdf, args): 
     62def execute(hdf, args, env): 
    6463    # Currently hdf is set only when the macro is called 
    6564    # From a wiki page 
     
    7271}}} 
    7372 
     73You can also use the environment (env) object to access configuration data. 
    7474 
    75  
     75Example. 
     76{{{ 
     77def execute(hdf, txt, env): 
     78    return env.get_config('trac', 'repository_dir') 
     79}}} 
    7680---- 
    7781See also:  WikiProcessors, WikiFormatting, TracGuide