[silva-dev] on-the-fly css/js inclusion with Porto Layout
j.bowlas at ucl.ac.uk
Wed Jun 22 10:21:05 CEST 2011
Thanks for the reply, hope you're having a great time in Florence.
On 21 June 2011 10:59, Sylvain VIOLLON <sylvain at infrae.com> wrote:
> On Mon, 20 Jun 2011 11:14 +0100, "Jonathan Bowlas" <j.bowlas at ucl.ac.uk>
>> Hi Devs,
> Greetings from EuroPython, under the sun of Italia.
>> 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
>> python:'\n'.join(request.other.setdefault('head', ));">
>> <tal:block content="structure head_content"/>
>> <tal:block metal:define-slot="content" content="structure
>> Then in our code source we do this:
>> src="http://www.ucl.ac.uk/js/jquery/ui.tabs.min.js"></script>' />
>> <tal:block define="zz python:request.other.setdefault('head',
>> So what is the recommended approach now?
> We didn't really changed anything about this in 2.3 (we didn't really
> touch the code sources).
> The head_inject should still work, or the solution you proposed should
> work as well.
> One of the feature of silva.core.layout is that in your content view,
> the update method of the content view is called before the layout is
> rendered (the template). That might help you as well if you are able
> to collect the needed JS or CSS at that time.
> In 3.0, with the changes we made we will be able to add two new
> parameters to code sources that will be a list of CSS and JS to
> include, that will be automatically included in the layout, we now
> have an architecture that let you do that, solving that long standing
> Sylvain Viollon -- Infrae
> t +31 10 243 7051 -- http://infrae.com
> Hoevestraat 10 3033GC Rotterdam -- The Netherlands
Web Support Officer
University College London
Email: j.bowlas at ucl.ac.uk
More information about the silva-dev