[Koha-devel] TT loop count VS size

Jonathan Druart jonathan.druart at bugs.koha-community.org
Fri May 7 09:57:31 CEST 2021


You should grep "loop.count", not ".count"
Most of the count you have with your regex is coming from
koha_objects->count

Le ven. 7 mai 2021 à 09:17, Fridolin SOMERS <fridolin.somers at biblibre.com>
a écrit :

> Hi community,
>
> I've been on a mindblowing search on a template error :D
>
> I was thinking that "loop.count" was wrong for testing if loop is not
> empty, the method is "loop.size".
>
> See doc
> http://template-toolkit.org/docs/manual/Directives.html#section_FOREACH
>
> Looks like we use both actually :
>   > git grep 'IF.*\.count ' origin/master | wc -l
> 602
>   > git grep 'IF.*\.size ' origin/master | wc -l
> 1636
>
> So using count seems to work because it starts with 1.
> But in my opinion it is a wrong call.
>
> We can see for example :
>   <a href="#images">Images ([% localimages.count || 0 | html %])</a>
> This is wrong no ?
>
> Should be create a coding guideline ?
>
> --
> Fridolin SOMERS <fridolin.somers at biblibre.com>
> Software and system maintainer 🦄
> BibLibre, France
> _______________________________________________
> Koha-devel mailing list
> Koha-devel at lists.koha-community.org
> https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
> website : https://www.koha-community.org/
> git : https://git.koha-community.org/
> bugs : https://bugs.koha-community.org/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.koha-community.org/pipermail/koha-devel/attachments/20210507/e4b0c515/attachment.htm>


More information about the Koha-devel mailing list