Re: Is there a way to defer whole mason component in Mason 2
Pedro Melo <[email protected]> Tue, 26 Feb 2013 15:49:13 +0000
| Newsgroups | gmane.comp.web.mason.user |
|---|---|
| Message-ID | <CACCxPi2n9VBJ_ohp-kCfn1aCntd+-edmJmbKrfSFPCrAc+2RyA@mail.gmail.com> |
Hi, On Fri, Feb 22, 2013 at 4:23 PM, roland16 <[email protected]> wrote: > Hi, > Let's say there is a component title.mi which contains some information > determined by child component of Base.mc. > 'title.mi' component is called in <%augment wrap> method of Base.mc like: > > <%class> > has 'title'; > </%class> > <%augment wrap> > % $.Defer {{ > <& 'title.mi' &> > % }} > <% inner() %> > </%augment> > > title.mi : > <% $.title %> > > The original 'title.mi' component is actually quite large and i don't want > to put the code inside Base.mc. > > Is there a way to set the 'title' attribute in child component of Base.mc > (i.e. index.mc by writing $.title('deferred value') ) so that 'title.mi' > will be executed with deferred value of 'title' attr? > The problem is that $.title in title.mi is not the same $.title in index.mc… They are different components, different object instances. In title, you need to access $m->page->title… I wrote a small proof-of-concept, you can find it here: https://github.com/melo/pocs/tree/master/mason_attrs See how $self is a different instance inside title.mi and index.mc. As I understand, defer method gets a block of code and inserts it into the > output at request end (executing this block by CODE->() and replacing the > markups with executed code). > I know that calling component via <& &>, which is eq to $m->comp, executes > the code that is inside. > $m->construct constructs and return a new instance of the component, but > is there a way to call a main method of this component by the Defer plugin? > Yes, $m->page. Bye, -- Pedro Melo @pedromelo http://www.simplicidade.org/ http://about.me/melo xmpp:[email protected] mailto:[email protected] ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_feb _______________________________________________ Mason-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mason-users