cmlenz@39: """Example macro.""" cmlenz@39: from trac.util import escape cmlenz@39: cmlenz@39: def execute(hdf, txt, env): cmlenz@39: # Currently hdf is set only when the macro is called cmlenz@39: # From a wiki page cmlenz@39: if hdf: cmlenz@39: hdf['wiki.macro.greeting'] = 'Hello World' cmlenz@39: cmlenz@39: # args will be `None` if the macro is called without parenthesis. cmlenz@39: args = txt or 'No arguments' cmlenz@39: cmlenz@39: # then, as `txt` comes from the user, it's important to guard against cmlenz@39: # the possibility to inject malicious HTML/Javascript, by using `escape()`: cmlenz@39: return 'Hello World, args = ' + escape(args)