(Didn' go through after more than 6 hours the first time I sent this, so
resending this)
Wektor wrote:
> could someone explain what is needed for CSSLink and JSLink to work?
Hi,
I browsed through the turbogears code just yesterday to get a better
understanding of this myself.
Basically, you create a JSLink/CSSLink or JSSource/CSSSource widget (see
turbogears/widgets/base.py) and either append it to the css/javascript
attribute of another widget or just include it in the dictionary
returned by your controller method.
The turbogears post processing than looks at our output dictionary and
for every object in it that supports it, it gets the JS/CSS via the
retrieve_css()/retrieve_javascript() method and appends it to the proper
tg_*/tg_css template variable, according to location. (see
_process_output() in turbogears/controllers.py).
The site template than looks at the tg_js_* and tg_css variables and
renders the widgets in the proper location (see
turbogears/view/templates/sitetemplate.kid).
Example:
from turbogears import controllers, expose
from turbogears.widgets import JSSource, js_location
class MyController(controllers.Controller):
@expose(template="myproject.templates.index")
def index(self):
myscript = JSSource("alert('Hello World!');",
js_location.bodybottom)
return dict(myscript=myscript)
Hope that helps.
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
-~----------~----~----~----~------~----~------~--~---
begin:vcard
fn:Christopher Arndt
n:Arndt;Christopher
adr:Fort Lorenzo;;Cuan Na Coille;Galway;Co. Galway;;Irland
email;internet:[EMAIL PROTECTED]
tel;work:+353 (0)91-745500
tel;cell:+353 (0)86-3378101
x-mozilla-html:TRUE
url:http://chrisarndt.de
version:2.1
end:vcard