Macros
Macros are executed whenever the sequence
"[[!name]]" or "[[!name
arg1="1" arg2="2"...]]" is found in a source page.
Webber itself doesn't define any macros, that's your task. Use custom Plugins for this.
Defining macros
A macro is a simply python function which returns HTML. The function needs
to be decorated with "@set_macro(name)". There's an example in
skeleton.py, which looks like:
@set_macro("sample")
def sample_macro(params):
if cfg.test_verbose:
print "in macro skeleton.sample_macro, params:", params
return "{ output of sample macro }"
If you call this macro, the returned text "{
output of sample macro }" will end up in your HTML file.
Inside the macro, you can access this parameters:
- "
params.name" contains the name of the macro - "
params.file" contains the current "class File" object
You can submit additional string arguments, e.g. with
"[[!sample arg1="string"]]". Now you get
additionally:
- "
params.arg1" contains "string"