Hi all,

I'm struggling with filtering out certain items in a FOREACH loop. Can
somebody please give me a tip?

The following code is from a bugzilla template that builds an HTML pulldown
list for all components of a product. I want to prevent components to appear
in that list whose name begins with "Z -". How do I do that?

 <td>
      <select name="component" onchange="set_assign_to();" size="5">
        [%- FOREACH c = product.components %]
               <option value="[% c.name FILTER html %]"
                 [% " selected=\"selected\"" IF c.name == default.component_
%]>
                 [% c.name FILTER html -%]
               </option>
           [%- END %]
      </select>
    </td>

I tried using the IF directive and the perl substr() method, but did not get
any matches. If I were to use the PERL directive, could a template block
access a variable that I define in a PERL block? If the PERL directive is
the only way to achieve my goal, how do I enable EVAL_PERL in bugzilla 3.0?

Thanks!
-- Daniela
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to