[Templates] How to do a wrapper with optional behavior

[prev] [thread] [next] [Date index for 2005/04/06]

From: Josh Varner
Subject: [Templates] How to do a wrapper with optional behavior
Date: 02:14 on 06 Apr 2005
Hello,

I am trying to use a splash tabbox and CGI::Application to create a
mode where you can switch behavior based on the tab selected, but I
don't want to create  a web page for each individual tab because they
vary mainly in setting rather than layout/functionality, and initially
I want the page to display a list of the modes available.

So, what I want in the main page is something like this
  where control_param is an auxiliary query parameter that specifies the submode

[% choices = { control_param_val1 => { link => 'url-to-mode1',
                                                                 text => 'Mode1'
                                                           
description => 'About Mode 1' },
                        control_param_val2 => { link => 'url-to-mode2',
                                                                 text => 'Mode2'
                                                           
description => 'About Mode 2' },
                         control_param_val3 => { link => 'url-to-mode3',
                                                                 text => 'Mode3'
                                                           
description => 'About Mode 3' },
                           } %]

[% WRAPPER choice_list 
  list = choices
  control = query_param
%]
   Do stuff with [% choice %]
[% END %]

If the parameter is set then the content of the wrapper is evaluated,
otherwise the default is to output a list of the modes and there
descriptions, I want to do this in a couple of places, but it seems
that the inside of the wrapper is evaluated prior to the wrapper code.

The stuff to do with choice is different and non-trivial in the
various places, but the default and framework is the same, so being
lazy I wanted to factor that part out, but I'm not sure how to do
that. I can't pass in the processed output of a block as I want the
wrapper to determine which sub mode is active. The closest I can think
of is passing in the name of a block to PROCESS. I was hoping there
was a more eloquent way and I was just missing it.

TIA,
Joshua Varner

_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

[Templates] How to do a wrapper with optional behavior
Josh Varner 02:14 on 06 Apr 2005

Generated at 14:44 on 11 Apr 2005 by mariachi v0.52