Thank you Vincent, (and Dave and Anthony)
I think I will definitely be able to work something out with your
suggestions.
As far as JS and CSS goes, I think I will attempt to serve the files
independently through a dhandler to force "Expires:" headers for those
files to avoid the repetitive 304's.
This will allow (I think) for a more modular management of the various
JS bits and pieces, and actually allow for a basic "version and
dependency management" of the JS and CSS libs (a la Maven).
If this fails, then I will fallback on a "deployment/build" script that
does the concatenation at the end of each development phase when the
site is ready to be deployed/tested.
Cheers, -Olivier
On Tue, 2008-11-11 at 10:28 -0500, Vincent Veselosky wrote:
> While I agree with Dave's assessment that JS and CSS files should be
> merged and included only once, nevertheless I recognize there are
> times when conditional inclusion of certain code in the header based
> on content lower in the page is necessary. For example, you might want
> to add a link tag pointing to an RSS feed that differs depending on
> the content requested. My solution to this is a bit of a hack, but it
> works for me.
>
> I use an application-specific key in Mason's "notes". At the top of
> the autohandler, set it to an array, like so:
>
> $m->notes('HTML_HEAD' => []);
>
> This is available to all the components in your request. Any component
> that wants to include a code snippet into the header pushes that
> snipped onto the array.
>
> push @{$m->notes('HTML_HEAD')}, $my_code_snippet;
>
> Finally, in the autohandler <%filter> section, you shove that code
> into the header using a regular expression replacement:
>
> <%filter>
> my $head = join "\n", @{$m->notes('HTML_HEAD')};
> s{</head>}{$head</head>};
> </%filter>
>
> Of course there's a lot of room for refinements there, like removing
> duplicates from the array, and the inherent fragility of the regexp,
> but in most cases something like this works fine.
>
> (Note, example code is off the top of my head, so don't necessarily
> copy and paste. :)
>
> Hope that helps.
>
> ----
> Vince Veselosky
> http://www.webquills.net
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users