<?xml version="1.0" encoding="windows-1252"?>
<node id="409143" title="Re^4: When to use templates?" created="2004-11-19 14:56:12" updated="2005-06-21 15:32:25">
<type id="11">
note</type>
<author id="272364">
MidLifeXis</author>
<data>
<field name="doctext">
&lt;P&gt;I agree mostly with that sentiment.  However, I have found myself putting display oriented variables in my perl code lately.&lt;/P&gt;
&lt;P&gt;For example, with HT, I would need to do a ...&lt;/P&gt;
&lt;CODE&gt;
# In the perl
$template-&gt;param(SHOULD_I_DISPLAY_THIS =&gt; ($foo + $bar) &gt; 2);
-------
&lt;!-- In the template --&gt;
&lt;TMPL_IF SHOULD_I_DISPLAY_THIS&gt;this&lt;/TMPL_IF&gt;
&lt;/CODE&gt;
&lt;P&gt;With HTE, I could use...&lt;/P&gt;
&lt;CODE&gt;
&lt;TMPL_IF EXPR="(FOO + BAR) &gt; 2"&gt;this&lt;/TMPL_IF&gt;
&lt;/CODE&gt;
&lt;P&gt;It leaves the display decisions in the hands of the interface / html coder, and the data collection to the perl program.  It is hard (you mentioned not having a TMPL_ELSIF) to do an N (where N&gt;2) way decision, or a decision based on the quantity of something.&lt;/P&gt;

&lt;P&gt;Another example...&lt;/P&gt;

&lt;P&gt;Without creating display variables in your perl code (x_gt_3, x_gt_5, ...), how would you change the style of something based on its value?&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Green if X &amp;lt; 3&lt;/LI&gt;
&lt;LI&gt;orange if 3 &amp;lt;= X &amp;lt; 5&lt;/LI&gt;
&lt;LI&gt;red if 5 &amp;lt;= X&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;As I said above, I typically don't like using HTE, but I am running into more instances where it could prove to be useful, and would remove some of the variables controling display from my perl code.&lt;/P&gt;

&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-272364"&gt;
&lt;P&gt;--MidLifeXis&lt;/P&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
409012</field>
<field name="parent_node">
409047</field>
</data>
</node>
