El Wed Oct 29 2014 at 1:40:34, Mark Tompsett (<mtompset@hotmail.com>) escribió:
Greetings,
<span style="block" title="[% SEARCH_RESULT.biblionumber |url %]" class="[% IF ( SEARCH_RESULT.normalized_ean ) %][% SEARCH_RESULT.normalized_ean %][% ELSE %][% SEARCH_RESULT.normalized_isbn %][% END %]" id="coce-thumbnail[% loop.count %]"></span>
This fails to meet coding guidelines (http://wiki.koha-community.org/wiki/Coding_Guidelines# HTML1:_Template_Toolkit_markup_inside_HTML) The question is does the following fail too?
<span style="block" title="[% SEARCH_RESULT.biblionumber |url %]" class="[% SEARCH_RESULT.normalized_ean || SEARCH_RESULT.normalized_isbn %]" id="coce-thumbnail[% loop.count %]"></span>
Because I really like it compared to the length IF/ELSE split.
Stick with the big IF/ELSE split. It is more readable and no point "optimizing" that way. Like this: [%- IF SEARCH_RESULT.normalized_ean -%] <span style="block" title="[%- SEARCH_RESULT.biblionumber |url -%]" class="[%- SEARCH_RESULT.normalized_ean -%] id="coce-thumbnail[%- loop.count -%]"></span> [%- ELSE -%] <span style="block" title="[%- SEARCH_RESULT.biblionumber |url -%]" class="[%- SEARCH_RESULT.normalized_isbn -%] id="coce-thumbnail[%- loop.count -%]"></span> [%- END -%] In more complex situations you could use template variables instead, for saving the correct value, something like: [%- IF SEARCH_RESULT.normalized_ean -%] [%- normalized_identifier = SEARCH_RESULT.normalized_ean -%] [%- ELSE -%] [%- normalized_identifier = SEARCH_RESULT.normalized_isbn -%] [%- END -%] <span style="block" title="[%- SEARCH_RESULT.biblionumber |url -%]" class="[%- normalized_identifier -%] id="coce-thumbnail[%- loop.count -%]"></span> Only if you think is worth te trouble, of course. Regards To+