[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cgiapp] Templates and display logic (was Re: [cgiapp] Re: CGI::App::DBH or Ima::DBI))


[BTW, thanks to all of you for the advice on using template systems.
Very interesting discussion and lots of useful info.]

> What are other specific features that would make TT attractive to an
> H::T user?

I haven't actually used TT or H::T much, but I've used a lot of custom
templating systems (due mostly to legacy issues and false hubris).

We recently had a situation where we had to hack our custom template
system to support basic arithmatic.  This would look something like
this:

   The value plus seven is: {|value+7|}

The reasons for this are a bit arcane, but bear with me.

We were using a javascript-based pull-down menu system in which items
on the menus are numbered statically in the HTML source.  Something like
this:

    menu_1_name = "Homepage"
    menu_1_link = "http://www.example.com/";
    menu_2_name = "Contact"
    menu_2_link = "/contact/"
    menu_3_name = "Products"
    menu_3_link = "/products/"

And so on.  The problem was: how to add a list of dynamically generated
items after a list of static items?  For instance:

    // products sub-menu
    sub_menu_3_1_name = "Widgets"
    sub_menu_3_1_link = "/widgets/"
    sub_menu_3_2_name = "Gizmos"
    sub_menu_3_2_link = "/gizmos/"

    // the rest of the products come from the database
    {|loop|*|
        sub_menu_3_{|counter+2|}_name = "{|product_name|}"
        sub_menu_3_{|counter+2|}_link = "{|product_link|}"
    |}

(please excuse the arcane template syntax here - the important part to
note is that the template itself knows how to add 2 to the counter.)

Anyway, the tricky bit is that the list of static products can grow or
shrink, and this static list is mantained in the template by the
designer (not the programmer).

In other words, since the Controller can't know that the dynamic list
starts counting at "2", the View really needs to know how to add.

I'm a big fan of keeping the M, V and C separate from each other, but I
also know from experience that presentation logic can sometimes be
complex.


Michael


--
Michael Graham
suppressed



---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.