Mercurial > genshi > genshi-test
diff examples/trac/wiki-macros/HelloWorld.py @ 39:71ecbe90aafc
Copy Trac to main branch.
author | cmlenz |
---|---|
date | Mon, 03 Jul 2006 18:53:27 +0000 |
parents | |
children |
line wrap: on
line diff
new file mode 100644 --- /dev/null +++ b/examples/trac/wiki-macros/HelloWorld.py @@ -0,0 +1,15 @@ +"""Example macro.""" +from trac.util import escape + +def execute(hdf, txt, env): + # Currently hdf is set only when the macro is called + # From a wiki page + if hdf: + hdf['wiki.macro.greeting'] = 'Hello World' + + # args will be `None` if the macro is called without parenthesis. + args = txt or 'No arguments' + + # then, as `txt` comes from the user, it's important to guard against + # the possibility to inject malicious HTML/Javascript, by using `escape()`: + return 'Hello World, args = ' + escape(args)