Of course now I found it out - short after I spend time to post the
question :-)

The related HTML code is defined by the template file in trac/
templates/layout.html (which is in my case in /usr/lib/python2.5/site-
packages/Trac-0.11.1-py2.5.egg/),
from line 23:
    <script py:for="script in chrome.scripts"
        type="${script.type}" src="${script.href}">${script.content}</
script>

After I changed it to:
    <script py:for="script in chrome.scripts" charset="$
{script.charset}"
        type="${script.type}" src="${script.href}">${script.content}</
script>
my test code started to work.
Still this doesn't do my trac macro any good, and I don't like to
implement a template provider just for this.

I might just file an enhancement ticket - at least the charset should
be user definable.

Martin

On Oct 31, 6:38 pm, "Martin S." <[EMAIL PROTECTED]> wrote:
> Hi,
> I know I can add javascript files to an trac page using add_script
> from trac.web.chrome inside the post_process_request method of an
> IRequestFilter object.
>
> I need now to set a javascript variable to a value read from the
> trac.ini in the HTML header. Any javascript file packeted with my code
> will be probably packed inside an EGG file, and I don't like to change
> these anyway.
> I would now add an script tag to the HTML head which includes a short
> javascript code sequence, ala:
>   <script type="text/javascript"> var abc = "1235534"; </script>
> but the add_script method doesn't provide this functionality.
> Its source code tells me that there is a 'scripts' set in req.chrome
> holding all the scripts:
>     script = {'href': href(path), 'type': mimetype}
>     req.chrome.setdefault('scripts', []).append(script)
>
> I tried to add a 'content' attribute (in different variations) to this
> set but this doesn't work - an empty script take is produced. I don't
> have time to go through the Trac, and maybe the Genshi, code further
> to find out where and how this scripts set is transformed  to HTML.
> Probably it really only takes the 'href' and 'type' arguments, because
> an valid 'charset' argument is also ignored.
>
> Does anyone now a solution for my problem?
> Martin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/trac-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to