On Wed, 26 Jul 2006, Kevin Old wrote:

> I know there's a cleaner way to do this.  All I want to do is print a
> word, but have more than one test case.  I'd like to do it in the <%
> %> print operator, but haven't been able to figure that out.
> 
> % if ( $ads = 'is_web' ) {
> Web Only
> % } elsif ( $ads = 'is_print' ) {
> Print
> % } else {
> Web and Print
> % }

Something like the following, assuming $ads is undef if not 'is_web' or 
'is_print':

<%once>
  my %route = (
    is_web   => 'Web Only',
    is_print => 'Print',
    default  => 'Web and Print',
  );
</%once>
%#
<%init>
  # ...
  $ads ||= 'default';
</%init>
%#

<td><% $route{$ads} %></td>

Or make a subcomponent or method out of your decision block, and then:

<td><& .route, ads => $ads &></td>

-- 
Michael

-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to