Re: [viewvc-users] Looking for a template variable

John Beranek <[email protected]>
Newsgroups gmane.comp.version-control.cvs.viewcvs.user
Organization Pace plc
Message-ID <[email protected]>
On 25/03/10 13:47, C. Michael Pilato wrote:
> John Beranek wrote:
>> Thanks, your verbatim patch didn't work, but the following did:
>>
>>      'request_uri' : request.get_url(),
>
> Oh, okay.  Cool.
>
>> On a similar topic, how easy would it be to add a variable to the
>> configuration and then pass that as a template variable. I ask because
>> using ViewVC on a master site and other mirror sites requires different
>> page elements. I'd like to be able to use the same code/templates
>> everywhere, but have conditional bits of the templates that show
>> different things on different sites.
>
> DISCLAIMER:
> I'm not really in a position to verify this right now, so it could be bogus.
>
> The templates are given access to the configuration via the [cfg] directive.
>   So perhaps you can create new configuration items in viewvc.conf under,
> say, the [general] section:
>
>     [general]
>     my_variable = foo
>
> And then in the templates, reference [cfg.general.my_variable]

Sorry for the late reply, it took a while before I had time to try this. 
It does work quite well except for one proviso. It seems you can't have 
conditional parts of templates that use config variables that may or may 
not be set. So, for example I couldn't do:

[if-any cfg.general.mirror_site]blah[end]

If 'mirror_site' wasn't defined in the config I would get a Python 
backtrace. The way I've worked around it is something like:

[is cfg.general.mirror_site "none"][else]blah[end]

This still relies on the config variable being set, but at least it 
allows sections to be turned off entirely by use of a special "none" value.

Cheers,

John.

-- 
John Beranek                         To generalise is to be an idiot.
http://redux.org.uk/                                 -- William Blake

------------------------------------------------------
http://viewvc.tigris.org/ds/viewMessage.do?dsForumId=4255&dsMessageId=2501508

To unsubscribe from this discussion, e-mail: [[email protected]].
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.