LP#1274999: Adjust TT syntax to match project style user/miker/lp1274999_next_link
authorMike Rylander <mrylander@gmail.com>
Wed, 22 Feb 2017 21:37:35 +0000 (16:37 -0500)
committerMike Rylander <mrylander@gmail.com>
Wed, 22 Feb 2017 21:37:35 +0000 (16:37 -0500)
Using a "$" sigil on a variable is confusing because that normally means
something special in TT, that the value of the variable, rather than the
variable name, should be used when accessing an array or hash by index or
key.

Instead, we can use the "last" vmethod provided for lists to directly
access the last element of the array, and then consult the size of that
list with "count".

Also removed is the sigil on the total_copies variable.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/templates/opac/parts/record/copy_table.tt2

index 92c3db9..535814e 100644 (file)
@@ -28,8 +28,7 @@ END;
 [%-
 IF has_copies; 
   # The "deepest" depth that a summary is available for determines how many total copies can be displayed here.
-  $depth = ctx.copy_summary.size - 1;
-  $total_copies = ctx.copy_summary.$depth.count;
+  total_copies = ctx.copy_summary.last.count;
 
 %]
 <table class="table_no_border_space table_no_cell_pad table_no_border" width="100%" id="rdetails_status">
@@ -262,7 +261,7 @@ END; # FOREACH bib
                     l('Previous [_1]', ctx.copy_offset - new_offset) %]</a>
             </td>
         [%- END %]
-        [%- IF copies.size >= ctx.copy_limit AND NOT serial_holdings AND (ctx.copy_offset + ctx.copy_limit > $total_copies) %]
+        [%- IF copies.size >= ctx.copy_limit AND NOT serial_holdings AND (ctx.copy_offset + ctx.copy_limit > total_copies) %]
             <td>
                 <a href="[% mkurl('', {copy_offset => ctx.copy_offset + ctx.copy_limit, copy_limit => ctx.copy_limit}) %]">[%
                     l('Next [_1]', ctx.copy_limit) %] &raquo;</a>
@@ -273,7 +272,7 @@ END; # FOREACH bib
         <tr>
             <td>
                 [%- more_copies_limit = 50 %] [%# TODO: config %]
-                [%- IF  ctx.copy_limit != more_copies_limit AND copies.size >= ctx.copy_limit AND $total_copies > ctx.copy_limit %]
+                [%- IF  ctx.copy_limit != more_copies_limit AND copies.size >= ctx.copy_limit AND total_copies > ctx.copy_limit %]
                     <div class="rdetail_show_copies">
                         <img src="[% ctx.media_prefix %]/images/plus_sign.png" alt="[% l('Show more copies icon') %]"/>
                         <a href="[% mkurl('', {copy_limit => more_copies_limit, copy_offset => 0}) %]">[% l('Show more copies') %]</a>