Jump to menu and information about this site.

Wednesday·25·January·2006

When writing Seamstress pages, componentize your tree transforms

Working with our Mason codebase today showed me something that would have been a lot harder in Seamstress. Basically, I was told to add a vonage advertisement in another table cell everywhere that we displayed a vbase_banner.

Up to this point, all pages using the vbase_banner looked something like this:

<& 'comp/related_topics_lander_2', aconf => $aconf, query => $query &>

<& 'comp/vbase_banner', aconf => $aconf, query => $query, align => 'left' &>

% if ($query->{'brand'} eq 'tbar') {
  <& 'comp/tbar_foot', aconf => $aconf, query => $query &>
% } else {
  <& 'comp/quickfoot', aconf => $aconf, query => $query, align => 'center' &>
% }

<& 'comp/footer', aconf => $aconf, query => $query &>


So all I had to do was toss a bit of logic in vbase_banner for the vonage_ad and I was done:

<tr> <td align='<% $align %>'><iframe width=468 height=60 noresize scrolling=no \frameborder=0 marginheight=0 marginwidth=0 src='http://t.trafficmp.com/b.t/<% $\id %>/<% $rn %>/'></iframe> </td> <td> % if ($query->{pagetype} ne &#8216;KEY&#8217;) { <& vonage_ad &> % } </td> </tr>

With Seamstress, one could componentize a page by creating subroutines for processing each part, but one does not have to. This is a downfall in Seamstress in a sense. But nevertheless, with Params::Validate and HTML::Tree, one can still do the trick, but one must be disciplined about placing each tree transformation into a separate subroutine instead of having a subroutine with a series of

The end result of disciplined Seamstress usage is that you can refine subroutines and make wholesale changes across several webpages if they all point to the same place


CatalystAdvent example converted from tt to Seamstress

You can view the source here and download via

svn co http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/CatalystAdvent-Seamstress

Charting Modules

  1. Chart by the Chart Group. seems like a focused set of people :)

My first Seamstress user!

I was elated to have a user of my module HTML::Seamstress. here is the bug he filed against Seamstress - and complete with a patch!

I am glad to have co-developer.

BookDB for Catalyst is done in HTML::Seamstress

I got HTML::Seamstress up and running the bookdb example. Thanks to Andy Grundman, I can commit to the examples directory on the Catalyst svn site so BookDB-Seamstress is available right here.

Converting it from tt to Seamstress led to a few improvements in HTML::Element::Library , namely the addition of iter2(), a more flexible routine for turning arrays of data into HTML list data, such as dl, ol, or ul.

I learned a lot about Class::DBI::AsForm in the process. That is a very slick module that is underdocumented and highly magical. I have pretty much decided to stick with DBIx::Simple for all of my database processing needs.

Perl Software Design Blog

About...

This is the weblog of the Perl Software Design Group.

Who We Are

Terrence Brannon
Matthew Sisk
Brock Wilcox
Gary Aston-Jones


Calendar

 2006 →
Months
Jan
 January 
Mo Tu We Th Fr Sa Su
           
25
         

Search


Advanced Search


Categories

Blogroll

People I know personally




Blogging Software Blogs