William Cox wrote: > i'm trying to do something funky here so i'll do my best to explain. i > have the component which is meant to dynamically wrap other widgets in > order to centrally handle caching, access control, etc... > > ideally it should be as transparent as possible and this includes > calling components with content. however because the content is passed > to this wrapper and not the target component this presents a bit of a > problem. what i would like is to re-pass that content on down into the > target component. Example: > > top_component.mas > ================ > <h1>Hello World!</h1> > <&| 'wrapper.mas', component => 'name.mas' &> > <% $ARGS{name} %> > </&> > > wrapper.mas > ========== > <%init> > $m->comp( { content => $m->content }, 'name.mas' ); > </%init> > > name.mas > ======== > <p>Good to meet you <% $m->content %></p> > > > This is an extremely simplified example of what i'm actually doing. > but you can see the problem in that the content effectively gets > executed twice. i'd like to call something like $m->content_ref that > can be used in the wrapper.mas so that when $m->content is called in > the target component it is calling exactly what was passed from the > parent component. > > thanks for your help. >
Before offering any advice, it might be a good idea for you to try and explain your motivation for doing this a bit more. I suspect that there are other, easier ways to do what you want. For example, authorization can be handled in an autohandler with: <%init> if (user_has_access) { $m->call_next; } else { $m->comp('/components/login.mas'); # or an error document } </%init> Where 'user_has_access' can involve calling some central function or component. Alternativly, you could put this in your root autohandler (so that you have no duplicated code) with something like this: <%init> unless ($m->user->has_access( $m->base_comp->attr('require') ) { $m->redirect('/', 301); # or whatever action you want to take } # ... $m->call_next; </%init> Where each component would have an <%attr> block specifying the required access: <%attr> require => 'admin' </%attr> Regards, Oliver.
signature.asc
Description: OpenPGP digital signature
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________ Mason-users mailing list Mason-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mason-users