on-the-fly css/js inclusion with Porto Layout

Jonathan Bowlas <j.bowlas-hclig2XLE9Zaa/[email protected]> Mon, 20 Jun 2011 11:14:06 +0100
Newsgroups gmane.comp.web.zope.silva.devel
Message-ID <[email protected]>
Hi Devs,

Could someone please explain how I could utilise the 'Injector for
on-the-fly css/js inclusion' in the porto mainlayout.pt to inject
scripts and stylesheets from a code source? This doesn't appear to be
documented anywhere.

When using SilvaLayout we did the following:

<HTML tal:define="rendered_ucl_content_area context/@@ucl_default_content_area;
                  head_content
python:'\n'.join(request.other.setdefault('head', []));">
 <HEAD>
  <tal:block content="structure head_content"/>
 </HEAD>
 <BODY>
  <tal:block metal:define-slot="content" content="structure
rendered_ucl_content_area"/>
 </BODY>
</HTML>


Then in our code source we do this:
<tal:block define='js string:<script type="text/javascript"
src="http://www.ucl.ac.uk/js/jquery/ui.tabs.min.js"></script>' />

<tal:block define="zz python:request.other.setdefault('head', []).append(js)"/>

So what is the recommended approach now?

Cheers

Jon

-- 
Jonathan Bowlas
Web Support Officer
Media Services
University College London
Email: j.bowlas-hclig2XLE9Zaa/[email protected]