annotate examples/trac/wiki-macros/HelloWorld.py @ 39:93b4dcbafd7b trunk

Copy Trac to main branch.
author cmlenz
date Mon, 03 Jul 2006 18:53:27 +0000
parents
children
rev   line source
39
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
1 """Example macro."""
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
2 from trac.util import escape
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
3
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
4 def execute(hdf, txt, env):
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
5 # Currently hdf is set only when the macro is called
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
6 # From a wiki page
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
7 if hdf:
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
8 hdf['wiki.macro.greeting'] = 'Hello World'
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
9
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
10 # args will be `None` if the macro is called without parenthesis.
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
11 args = txt or 'No arguments'
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
12
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
13 # then, as `txt` comes from the user, it's important to guard against
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
14 # the possibility to inject malicious HTML/Javascript, by using `escape()`:
93b4dcbafd7b Copy Trac to main branch.
cmlenz
parents:
diff changeset
15 return 'Hello World, args = ' + escape(args)
Copyright (C) 2012-2017 Edgewall Software