Re: Delayed output generation feature?

Doug Treder <[email protected]>
Newsgroups gmane.comp.web.mason.devel
Message-ID <[email protected]>
Plugins are another way to do this.  Using a plugin for this would be 
similar to using a filter, but on the plus side,  plugins do know which 
components get called (they get notified for every component).  On the 
downside, plugins typically aren't as flexible as components since they 
are full-on objects.

-Doug


Dave Rolsky wrote:

> I've come up with an idea for a feature that is similar to one Jon has 
> proposed in the past, which he called placeholders, though I think my 
> idea of how it should work is slightly different.
>
> Basically, what I'd like to do is mark a spot in the output as it's 
> being generated and say "fill this in later".  The filling in would be 
> done by calling a code reference.
>
> So for example I might have something like this:
>
>  <html>
>  <head>
>  % $m->delayed_output( sub { $m->comp('/lib/javascript_links.mas' ) } );
>  </head>
>  ...
>  </html>
>
> The idea here is that the code above would go in the autohandler but 
> that any subsequently called components could do something to 
> determine what JS links are generated.
>
> The return value of $m->delayed_output() would be an object 
> encapsulating the code reference.
>
> Of course, you can already get a _similar_ effect using filters.  You 
> _can't_ do this with methods because you don't know what all of the 
> components that will be called are.
>
> There's a couple things to consider to make this feature work:
>
> 1. It won't work when autoflush is on, obviously.  I'd suggest that 
> calling the delayed_output() method just die if autoflush is on.
>
> 2. In the code in head, output is simply concatenated to a scalar 
> reference.  This is a speed optimization (over using the buffer 
> objects we currently use).
>
> To make this new feature work, we'd probably have to push items into 
> an array instead.  Then when we go to send output we can iterate over 
> the array.  If the array element is a plain scalar, we just send it.  
> If it's a HTML::Mason::DelayedOutput object we call a method on it.
>
> This'd be slower than what's there but faster than the current stable 
> code.
>
>
> So things to think about ...
>
> - Is this a worthwhile feature?
>
> - Is there a better/faster/cooler way to implement it?
>
> - How to handle calls to flush_buffer when this has been used?  Just 
> call the coderef then?  die?
>
>
> -dave
>
> /*===================================================
> VegGuide.Org                        www.BookIRead.com
> Your guide to all that's veg.       My book blog
> ===================================================*/
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
> Tool for open source databases. Create drag-&-drop reports. Save time
> by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
> Download a FREE copy at http://www.intelliview.com/go/osdn_nl
> _______________________________________________
> Mason-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mason-devel



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.