Mercurial > genshi > mirror
view examples/trac/wiki-macros/HelloWorld.py @ 92:01d36818bb3d trunk
More performance improvements... this time for whitespace normalization and template loops.
author | cmlenz |
---|---|
date | Thu, 20 Jul 2006 23:06:36 +0000 |
parents | 93b4dcbafd7b |
children |
line wrap: on
line source
"""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)