Edgewall Software

Changes between Version 14 and Version 15 of WikiMacros


Ignore:
Timestamp:
Oct 31, 2005, 3:38:16 PM (19 years ago)
Author:
Christopher Lenz
Comment:

Cleanup

Legend:

Unmodified
Added
Removed
Modified
  • WikiMacros

    v14 v15  
    22Trac 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
    4 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.
     4Another kind of macros are WikiProcessors. They typically deal with alternate markup formats and representation of larger blocks of information (like source code highlighting).
    55
    66== Using Macros ==
     
    2323== Available Macros ==
    2424
    25 Macros are still a relatively new feature, and the list of available (and distributed) macros is
    26 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).
    27 
    28   ''Note that the following list will only contain the macro documentation if you've not enabled `-OO` optimizations, or not set the `PythonOptimize` option for [wiki:TracModPython mod_python].''
     25''Note that the following list will only contain the macro documentation if you've not enabled `-OO` optimizations, or not set the `PythonOptimize` option for [wiki:TracModPython mod_python].''
    2926
    3027[[MacroList]]
    3128
    3229== Macros from around the world ==
    33 The [http://projects.edgewall.com/trac/ Trac Project] has a section dedicated to user-contributed macros, [wiki:MacroBazaar 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 [wiki:MacroBazaar MacroBazaar] wiki page.
    34 
    35   http://projects.edgewall.com/trac/wiki/MacroBazaar
    36 
     30The [http://projects.edgewall.com/trac/ Trac Project] has a section dedicated to user-contributed macros, [http://projects.edgewall.com/trac/wiki/MacroBazaar 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 [http://projects.edgewall.com/trac/wiki/MacroBazaar MacroBazaar] wiki page.
    3731
    3832----
    3933
    40 
    41 == Developing New Macros ==
     34== Developing Custom Macros ==
    4235Macros, like Trac itself, are written in the [http://www.python.org/ 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.
    4336
     
    5144}}}
    5245
    53 === Advanced Topics: Template-enabled Macros ===
    54 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.
    55 
    56 Macros gain direct access to the main HDF tree, and are free to manipulate it.
    57 
    58 Example:
    59 {{{
    60 #!python
    61 def execute(hdf, args, env):
    62     # Currently hdf is set only when the macro is called
    63     # from a wiki page.
    64     if hdf:
    65         hdf.setValue('wiki.macro.greeting', 'Hello World')
    66        
    67     # args will be null if the macro is called without parentheses.
    68     args = args or 'No arguments'
    69     return 'Hello World, args = ' + args
    70 }}}
    71 
    72 You can also use the environment (env) object to access configuration data.
    73 
    74 Example.
     46You can also use the environment (`env`) object, for example to access configuration data and the database, for example:
    7547{{{
    7648#!python
     
    7951}}}
    8052
    81 Here is information on the different WikiMacroObjects.
     53Note that since version 0.9, wiki macros can also be written as TracPlugins. This gives them some capabilities than “classic” macros do not have, such as directly access the HTTP request.
     54
     55For more information about developing macros, see the [http://projects.edgewall.com/trac/wiki/TracDev development resources] on the main project site.
    8256
    8357----
    84 See also:  WikiProcessors, WikiFormatting, TracGuide, WikiMacroObjects
     58See also:  WikiProcessors, WikiFormatting, TracGuide