in reply to Output should have multiple segments

Here is another way to put CSS into the main document from a component. This is based on the filter mechanism so will work even if the component isn't a top-level one

In autohandler
<html> <head> <style> /* default styling here */ __MYCSS__ </style> </head> <body> ... <% $m->call_next %> ... </body> </html> <%filter> s/__MYCSS__/$m->notes('mycss')/e </%filter>
In the called component
... <%init> ... $m->notes(mycss => 'your css here'); </%init>

Replies are listed 'Best First'.
Re^2: Output should have multiple segments
by John M. Dlugosz (Monsignor) on Jul 17, 2008 at 02:17 UTC
      $m->notes is very useful.

      That said, I dislike & mistrust using Mason's filter stuff, though there are times & ways in which I think it is the most expedient option.
        I guess notes was added after the books were written. It's basically global variables that don't need to be declared. Handy to have a component "return" the generated text but still be able to present values back to the caller. Gee, I thought that was all evil stuff? Making it seem new again for a new generation!

        I've not used Filter yet, but I'm less concerned if filtering individual components such as to mark the current page in a navigation menu, because you can be sure what to expect in the text to grep.

        —John