wiki:ArbitraryOptionsPlugin

Pass configuration options to Trac templates

Description

This plugin allows you to pass arbitrary options from conf.ini's to templates in Trac.

You put whatever options you'd like in a [project_info] stanza inside your Trac's .ini file. These are passed to the template as key-value pairs inside the dictionary 'project_info'.

You can also access data for other projects in your trac env under the list 'projects'. That list will have a dictionary with keys 'name', 'description', 'href', and 'info', where the first three are the same as in a project list, and the 'info' is the dictionary of arbitrary options you've passed for that project.

You can do this for your project listing page too, using the ArbitraryProjectPropertiesPatch.

Note that this is only implemented for Genshi at present, but you could add a line or two for ClearSilver, although this is untested.

Bugs/Feature Requests

Existing bugs and feature requests for ArbitraryOptionsPlugin are here.

If you have any issues, create a new ticket.

Download

Download the zipped source from here.

Source

You can check out ArbitraryOptionsPlugin from here using Subversion, or browse the source with Trac.

Installation

General instructions on installing Trac plugins can be found on the TracPlugins page.

You can also just run:

$ easy_install TracArbitraryOptionsPlugin

Example

If your trac.ini file had this:

[project_info]
short_name = my_project
status = active
order = 3

You could access it in your Trac's Genshi templates like this:

Short name is ${project_info.get('short_name')}. Status is ${project_info.get('status')}. Order is ${project_info.get('order')}.

You could iterate over your whole projects list like this:

<li py:for='proj in projects' py:if='proj.name != project.name and proj.info.get("status") == "primary">
    <a href='/${proj.href}'>${proj.name}</a>;
</li>

See also http://www.siafoo.net/snippet/276 for more information.

See http://projects.icapsid.net/adjector for a usage example.

Recent Changes

11845 by rjollos on 2012-07-31 08:42:12
Removed egg.
7494 by david on 2010-02-03 19:59:49
Initial Commit
7493 by david on 2010-02-03 19:33:55
New hack ArbitraryOptionsPlugin, created by david
(more)

Author/Contributors

Author: david
Maintainer: David
Contributors:

Last modified 8 months ago Last modified on Nov 24, 2015, 4:26:45 PM