Package trac :: Package wiki :: Module api :: Class IWikiMacroProvider

Class IWikiMacroProvider

source code

    object --+    
             |    
core.Interface --+
                 |
                IWikiMacroProvider

Augment the Wiki markup with new Wiki macros.

.. versionchanged :: 0.12
   new Wiki processors can also be added that way.

Instance Methods
 
get_macros()
Return an iterable that provides the names of the provided macros.
source code
 
get_macro_description(name)
Return a tuple of a domain name to translate and plain text description of the macro or only the description with the specified name.
source code
 
render_macro(req, name, content)
Return the HTML output of the macro :deprecated:
source code
 
is_inline(content)
Return `True` if the content generated is an inline XHTML element.
source code
 
expand_macro(formatter, name, content, args=None)
Called by the formatter when rendering the parsed wiki text.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

get_macro_description(name)

source code 
Return a tuple of a domain name to translate and plain text
description of the macro or only the description with the specified
name.

.. versionchanged :: 1.0
   `get_macro_description` can return a domain to translate the
   description.

is_inline(content)

source code 
Return `True` if the content generated is an inline XHTML element.

.. versionadded :: 1.0

expand_macro(formatter, name, content, args=None)

source code 
Called by the formatter when rendering the parsed wiki text.

.. versionadded:: 0.11
  This form is preferred over `render_macro`, as
  you get the `formatter`, which knows the current `.context`
  (and the `.req`, but ideally you shouldn't use it in your
  macros).
.. versionchanged:: 0.12
   added the `args` parameter

:param formatter: the wiki `Formatter` currently processing
  the wiki markup

:param name: is the name by which the macro has been called;
  remember that via `get_macros`, multiple names could be
  associated to this macros. Note that the macro names are
  case sensitive.

:param content: is the content of the macro call. When called
  using macro syntax (`[[Macro(content)]]`), this is the
  string contained between parentheses, usually containing
  macro arguments. When called using wiki processor syntax
  (`{{{!#Macro ...}}}`), it is the content of the processor
  block, that is, the text starting on the line following the
  macro name.

:param args: will be a dictionary containing the named
  parameters passed when using the Wiki processor syntax.

  The named parameters can be specified when calling the macro
  using the wiki processor syntax::

    {{{#!Macro arg1=value1 arg2="value 2"`
    ... some content ...
    }}}

  In this example, `args` will be
  `{'arg1': 'value1', 'arg2': 'value 2'}`
  and `content` will be `"... some content ..."`.

  If no named parameters are given like in::

    {{{#!Macro
    ...
    }}}

  then `args` will be `{}`. That makes it possible to
  differentiate the above situation from a call
  made using the macro syntax::

     [[Macro(arg1=value1, arg2="value 2", ... some content...)]]

  in which case `args` will always be `None`.  Here `content`
  will be the
  `"arg1=value1, arg2="value 2", ... some content..."` string.
  If like in this example, `content` is expected to contain
  some arguments and named parameters, one can use the
  `parse_args` function to conveniently extract them.