39
|
1 """Example macro."""
|
|
2 from trac.util import escape
|
|
3
|
|
4 def execute(hdf, txt, env):
|
|
5 # Currently hdf is set only when the macro is called
|
|
6 # From a wiki page
|
|
7 if hdf:
|
|
8 hdf['wiki.macro.greeting'] = 'Hello World'
|
|
9
|
|
10 # args will be `None` if the macro is called without parenthesis.
|
|
11 args = txt or 'No arguments'
|
|
12
|
|
13 # then, as `txt` comes from the user, it's important to guard against
|
|
14 # the possibility to inject malicious HTML/Javascript, by using `escape()`:
|
|
15 return 'Hello World, args = ' + escape(args)
|