Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I wonder how the fellowmonks pass their model objects into templates. Do you pass directly the objects or do you expand them into individual properties (pass them as hashrefs)?

If you use the first method (objects) how do you pass the additional information for the object?

Let us say we need to display a list of some kind of payments (DBIx::Class objects). It could be comfortable just:

$c->stash(payments => \@payments);

But there are other information we need to supply with each payment:

  • URLs (for payment detail, payment cancellation)
  • textual descriptions for foreign keys values ( payment state, payment method, ...)
  • other payment properties not contained in the payment object. For example whether payment is due (would be displayed in red).

So would you pass the list like this:

$c->stash->{payments} = [ map { { is_due => $this->is_due( $c, $_ ), cancel_url => $c->uri_for_action( '/payment/cancel', [ $_- +>id ] ), detail_url => $c->uri_for_action( '/payment/view', [ $_- +>id ] ), payment_method => $this->payment_method_descr_for( $c, $_->payment_metho +d_id ), # how about the original object ? payment => $_, # or payment_id => $_->id, payment_quantity => $_->quantity, # .... } } @payments ];
or would you pass just the payments and compute the additional info (and URLs) in template (It doesn't seem very MVCish to me)?

Finally how do you pass dates? As objects or formatted already?

Any comments are really appreciated.

In reply to How to organize Catalyst stash by roman

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    [erix]: ( also: UniCorn Throne )
    [zentara]: erix I hope both tusks pointed in the same direction :-)
    LanX "♪..♫ Last night a DJ killed my wife ♪..♫ "
    zentara...oO 1 more reason I prefer Perl to Python is I can't believe how long Python takes to compile, and you can't disable the myriad of tests
    [LanX]: so that's where you've been the last two years? Compiling Python?
    [zentara]: LanX no! I was learning why Krishna made me into a unicorn. :-)

    How do I use this? | Other CB clients
    Other Users?
    Others cooling their heels in the Monastery: (10)
    As of 2017-03-30 16:43 GMT
    Find Nodes?
      Voting Booth?
      Should Pluto Get Its Planethood Back?

      Results (361 votes). Check out past polls.