Changes between Version 2 and Version 3 of WikiMacros
- Timestamp:
- Mar 11, 2007, 2:32:45 AM (18 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
WikiMacros
v2 v3 5 5 6 6 == Using Macros == 7 Macro calls are enclosed in two ''square brackets''. Like python functions, macros can also have arguments, a comma separated list within parentheses.7 Macro calls are enclosed in two ''square brackets''. Like Python functions, macros can also have arguments, a comma separated list within parentheses. 8 8 9 9 === Examples === … … 28 28 29 29 == Macros from around the world == 30 The [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.31 30 32 ---- 31 The [http://trac-hacks.org/ Trac Hacks] site provides a wide collection of macros and other Trac [TracPlugins plugins] contributed by the Trac community. If you're looking for new macros, or have written one that you'd like to share with the world, please don't hesitate to visit that site. 33 32 34 33 == Developing Custom Macros == 35 Macros, 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.34 Macros, 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 `execute()` function. Trac will display the returned data inserted into the HTML representation of the Wiki page where the macro is called. 36 35 37 36 It's easiest to learn from an example: … … 48 47 #!python 49 48 def execute(hdf, txt, env): 50 return env. get_config('trac', 'repository_dir')49 return env.config.get('trac', 'repository_dir') 51 50 }}} 52 51 53 Note that since version 0.9, wiki macros can also be written as TracPlugins. This gives them some capabilities tha n “classic” macros do not have, such asdirectly access the HTTP request.52 Note that since version 0.9, wiki macros can also be written as TracPlugins. This gives them some capabilities that “classic” macros do not have, such as being able to directly access the HTTP request. 54 53 55 54 For more information about developing macros, see the [http://projects.edgewall.com/trac/wiki/TracDev development resources] on the main project site.