in reply to HTML::Template - loop order

i only want one pipe | between the items, like in perl join

turn on loop_context_vars and use __last__

<TMPL_VAR NAME=ID>: <TMPL_VAR NAME=NAME><br> <TMPL_LOOP NAME=CATEGORIES> <TMPL_VAR NAME=ID>/<TMPL_VAR NAME=TITLE> <TMPL_UNLESS NAME=__last__>|</TMPL_UNLESS> </TMPL_LOOP>

Replies are listed 'Best First'.
Re^2: HTML::Template - loop order
by tinita (Parson) on Aug 03, 2004 at 18:49 UTC
    turn on loop_context_vars and use __last__
    great, thanks. saved my day =)
    next time i'll read the docs more carefully

      concerning the second problem I can suggest two ways

      • If you can use unique names for you LOOPs in a html, then you may use global vars like "SOMENAME_REVERSED" in the begin of html not inside of deep structures
      • If your LOOPs are not huge then you may provide the both direct and reversed representations of the list for each LOOP. e.g. <TMPL_LOOP NAME='NAME'> and <TMPL_LOOP NAME='NAME_REVERSED'>. So you don't need to detect anything
        If you can use unique names for you LOOPs ...
        yes, i actually can (but in this early stage i might redesign the whole thing...). but that's a nice idea. then i don't need to query() the template just need to query the template once.
        If your LOOPs are not huge then
        that's something i don't know. the code should be good for any kind of data. but that might be a good candidate for an option like use MyModule qw(auto_reverse) or something.