Re: [PATCHv5 08/12] gitweb: auxiliary function to group data
- From
Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
- Date
- Sep 27, 2010, 07:26 UTC
- Message-ID
- <AANLkTimOJ7RXDWXy=tF+rZf1gnfB7_GHCZuU5bZ5Wc91@mail.gmail.com>
- In-Reply-To
- <201009262347.15779.jnareb@gmail.com>
2010/9/26 Jakub Narebski <jnareb@gmail.com>:
Show 7 quoted lines
> On Fri, 24 Sep 2010, Giuseppe Bilotta wrote: > >> Subject: gitweb: auxiliary function to group data >> > > Errr... what!? git_group() is not "auxiliary function to group data", > but a template for output of group of data.
I will rephrase
> It would be probably good to describe how this output looks like > (using e.g. ASII-art mockup) in a commit message.
Well, that would depend on the CSS that is used ... should I squash the styling in this patch then?
>> +sub git_group {
>
> Name?git_collection? git_collect_data? I'm a little short on ideas. git_section? git_subsection? the function (with different styling) can probably be used even for the main sections in each view (think summary view in particular).
Show 28 quoted lines
>> + my ($class, $id, @rest) = @_;
>> +
>> + my $content_func = pop @rest;
>> +
>> + $class = join(' ', 'group', $class);
>> +
>> + print $cgi->start_div({
>> + -class => $class,
>> + -id => $id,
>> + });
>> + git_print_header_div(@rest);
>> + $content_func->() if defined $content_func;
>
> More defensive programming would be to use
>
> + $content_func->() if ref($content_func) eq 'CODE';
>
> Or even:
>
> + if (ref($content) eq 'CODE') {
> + $content->();
> + } elsif (ref($content) eq 'ARRAY') {
> + print @$content;
> + } elsif (!ref($content) && defined($content)) {
> + print $content;
> + }
>
> Well, $content could be also open filehandle...Ah, very interesting and very flexible, I'll steal your idea.
-- Giuseppe "Oblomov" Bilotta