wikimacros
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | wikimacros [2015/06/09 15:23] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== | ||
+ | Trac macros are plugins to extend the Trac engine with custom ' | ||
+ | |||
+ | Another kind of macros are WikiProcessors. They typically deal with alternate markup formats and representation of larger blocks of information (like source code highlighting). | ||
+ | |||
+ | ===== Using Macros ===== | ||
+ | Macro calls are enclosed in two //square brackets//. Like Python functions, macros can also have arguments, a comma separated list within parentheses. | ||
+ | |||
+ | ==== Examples ==== | ||
+ | |||
+ | < | ||
+ | | ||
+ | </ | ||
+ | |||
+ | Display: | ||
+ | | ||
+ | |||
+ | < | ||
+ | | ||
+ | </ | ||
+ | |||
+ | Display: | ||
+ | | ||
+ | |||
+ | ===== Available Macros ===== | ||
+ | |||
+ | '' | ||
+ | |||
+ | [[: | ||
+ | |||
+ | ===== Macros from around the world ===== | ||
+ | |||
+ | The [[http:// | ||
+ | |||
+ | ===== Developing Custom Macros ===== | ||
+ | Macros, like Trac itself, are written in the [[http:// | ||
+ | |||
+ | It's easiest to learn from an example: | ||
+ | < | ||
+ | #!python | ||
+ | # MyMacro.py -- The world' | ||
+ | |||
+ | def execute(hdf, | ||
+ | return "Hello World called with args: %s" % args | ||
+ | </ | ||
+ | |||
+ | |||
+ | You can also use the environment (`env`) object, for example to access configuration data and the database, for example: | ||
+ | < | ||
+ | #!python | ||
+ | def execute(hdf, | ||
+ | return env.config.get(' | ||
+ | </ | ||
+ | |||
+ | |||
+ | 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. | ||
+ | |||
+ | For more information about developing macros, see the [[http:// | ||
+ | |||
+ | ---- | ||
+ | See also: WikiProcessors, | ||
wikimacros.txt · Last modified: 2015/06/09 15:23 by 127.0.0.1