On Sun, 19 Oct 2003, Mark Fuller wrote:

> Now, in a template I might have an option box for "male or female". In
> Spanish, "hombre or mujer." This language difference is kept in the
> template, and an ordinal is used to communicate to the scripts what the
> choice was. Regardless of language, "1" is a male, and "2" is a female. So,
> in this case, it would defeat the strength of templates to call some other
> device to emit the option box. I'd have to store the language text in a
> MySQL table and pass it to the device that will create the option box. I'd
> rather not do that since the text logically belongs in the template instance
> for that language.

Sounds like a compelling case for building the <select> in the
template.  Either that or you need to go to some kind of gettext-style
i18n database.  You might need that anyway, for error messages and
other generated text.

> Now that I think about it, I believe I could set a param name for "one" and
> "two" and "three" but instead of making them true and false (and using an if
> statement) I could set the correct one to "selected" and just let each
> variable be replaced by its value. Only one would have "selected" and it
> would be emitted at the correct option line.

That works.  Something like:

  <option value="foo" <tmpl_if foo_selected>selected</tmpl_if>>Foo</option>
  <option value="bar" <tmpl_if bar_selected>selected</tmpl_if>>Bar</option>

Then you just set one "${name}_selected" to 1.

> Do you know if it would be more efficient to set one var and use a
> conditional to determine which option select line to treat differently. Or,
> set many vars and let them all be replaced (to null except one).

If you can avoid using HTML::Template::Expr then you should.  It's
much slower than HTML::Template and uses more memory.  But if you have
to use it anyway then it won't matter much which path you choose.

If you're worried, try both and let Benchmark.pm decide!

-sam


-------------------------------------------------------
This SF.net email sponsored by: Enterprise Linux Forum Conference & Expo
The Event For Linux Datacenter Solutions & Strategies in The Enterprise 
Linux in the Boardroom; in the Front Office; & in the Server Room 
http://www.enterpriselinuxforum.com
_______________________________________________
Html-template-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/html-template-users

Reply via email to