Remi Jolin - SysGroup schrieb:
> le 27.08.2008 17:35 Matt Wilson a écrit:
>> Hi -- If a template depends on a few stylesheets and javascript files,
>> is there any way to pull those without adding them manually to the
>> template?  Can the controller handle that?
>>
>>   
> You can create a widget like this
> class MyJS(widgets.Widget):
>     javascript = [JSLink(...), ...]
>     css = [...]
> 
> and then define
> my_js = MyJS()
> and pass my_js in your output dict of your controller method.

You can also add the JSLink and CSSLink widgets directly to the output
dict or wrap them in a widgets.WidgetList instance:

    @expose()
    def foo(self):
        return dict(js=JSLink(...), css=CSSLink(...))

or (TG > 1.0.6 only):

    @expose()
    def foo(self):
        return dict(widgets=WidgetList(JSLink(...), CSSLink(...)))

Or you add the full path to the CSSLink/JSLink widget *instances* to the
'tg.include_widgets' setting in your app's configuration.


   tg.include_widgets = [mypkg.widgets.my_css, mypkg.widget.my_js]

Then the CSS/JS links will be added to *every* template output.


Chris

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to