in reply to Output should have multiple segments

Try inheritance, e.g. in your autohandler
<html> <head> <style> /* default styling here */ <& SELF:.add_style &> </style> </head> <body> ... <% $m->call_next %> ... </body> </html> <%method .add_style> </%method>
Then in another component (say mylist.html) that inherits from the autohandler
... <%method .add_style> /* custom styling here */ </%method>
This way when mylist.html is requested, the custom css will get added within the html header.

Alternatively you could build the a css file dynamically and let Mason handle it. E.g. in each component where you want to add CSS to that of the overall page, you could write the css to a database table, and then when Mason serves the css page, it could query the database for the css and generate an appropriate css page.

I'll also highly recommend the Mason book if you haven't been reading it.

Replies are listed 'Best First'.
Re^2: Output should have multiple segments
by AltBlue (Chaplain) on Jul 19, 2008 at 14:21 UTC
    You can avoid having to define dummy methods in your autohandlers (i.e. .add_style) and reduce output cluttering (i.e. empty style blocks) by testing if such "plugs" were defined:
    % if ( $m->request_comp->method_exists('.add_style') ) { <style><& SELF:.add_style &></style> % }

    --
    altblue.

Re^2: Output should have multiple segments
by John M. Dlugosz (Monsignor) on Jul 17, 2008 at 02:03 UTC
    The inheritance is not a complete solution, because the use of a contained component doesn't have any effect. You would have to manually override the method in the same component that contains components, and add the stuff to it.

    The database idea is interesting.