Mechanism to use Macros within Templates

0 views
Skip to first unread message

Ilias Lazaridis

unread,
Feb 2, 2007, 8:38:04 AM2/2/07
to Trac Development
I would like to provide a wiki template in order to include the
TracNav Macro (and some others) by default.

Is there any mechanism available to call macros from within templates?

.

--
http://dev.lazaridis.com/base

Thomas Moschny

unread,
Feb 2, 2007, 9:03:53 AM2/2/07
to trac...@googlegroups.com
On Friday 02 February 2007 14:38, Ilias Lazaridis wrote:
> I would like to provide a wiki template in order to include the
> TracNav Macro (and some others) by default.
>
> Is there any mechanism available to call macros from within templates?

I guess you already tried the various incarnations of WikiInclude
macros/plugins and the TracWikiTemplates plugin, and that didn't work?

- Thomas

Ilias Lazaridis

unread,
Feb 2, 2007, 11:37:06 AM2/2/07
to Trac Development

Ο/Η Thomas Moschny έγραψε:

this would not work by design.

The requirements are:

* no need to modify the wikipages
* ability to switch the extension on/off (Component)

I've implemted this manually for the AutoNav Macro.

If the component "WikiBacklinks" is enabled, the AutoNav result
becomes available on every page:

http://dev.lazaridis.com/base/browser/infra/tracx/tracx/menus.py?rev=162#L110

But this is not a generic solution (e.g. applicable to the TracNav or
other macros), because i use a copy of the macro and insert it's
output over a variable into a custom template.

So my request is essentially, how would one implement such a solution
in a generic way?

class WikiApplyMacroToAllPages(Component):

# which event to claim

# how to access/call a macro
<access-path>.MacroName.<function>(<parameters>)

Ilias Lazaridis

unread,
Feb 5, 2007, 7:52:00 AM2/5/07
to Trac Development

On Feb 2, 3:38 pm, "Ilias Lazaridis" <i...@lazaridis.com> wrote:
> I would like to provide a wiki template in order to include the
> TracNav Macro (and some others) by default.
>
> Is there any mechanism available to call macros from within templates?

I've implemented this based on a workaround, using

46 <div py:if="chrome.nav['tracnav']">
47 ${wiki_to_html('[[TracNav]]')}
48 </div>

http://dev.lazaridis.com/base/changeset/189

-

But this functionality should be provided somehow from within trac:

http://trac.edgewall.org/ticket/4660

-

as a side-question: How can I ask in the template, if one component is
enabled?

Something like:

<div py:if="tracx.menue.MyComponent.enabled">

.

--
http://dev.lazaridis.com/base

Reply all
Reply to author
Forward
0 new messages