HTML-Pen

 view release on metacpan or  search on metacpan

lib/HTML/Pen.pm  view on Meta::CPAN

    <table>
      <: &iterate( *states, @ROW )>
    </table>

This example illustrates blocks that are nested to correspond with the data
set, in parent-child relationships.  Each block recurses by calling
C<iterate()> with the common iterator and the name of the child 
block.

L<HTML::Pen::Iterator> illustrates a relatively sophisticated example of a 
4 dimensional data set calendar to be presented as a table.  The iterator data 
consists of an array of weeks; each week consists of an array of days; each 
day consists of an array of times; each time consists of an array of events.  
Each event is represented by an event object that is a blessed hash reference.

With a Pen iterator, the rendering code is a few simple lines of HTML.  The
complexity is absorbed in the data structure, which should be defined as
follows:

  \@week -> \@day -> \@time -> \%event

lib/HTML/Pen/Iterator.pod  view on Meta::CPAN

# Below is stub documentation for your module. You'd better edit it!

=head1 NAME

HTML::Pen::Iterator - Creating a calendar using a Pen Iterator

=head1 SYNOPSIS

    <: &do( 'festival.pl' )>
    <: &iterator( *events, $festival )>
    <: &iterator( *active, $$festival[1] )>
    
    <: &block( *HEADER, 'endblock' )>
      <td class="calendarHeader">
        <: &iteratorValue( *active, 'weekday' )>
      </td>
    endblock
    
    <: &block( *WEEK, 'endblock' )>
    <tr>
    <: &undef( $#$events = 6 )>
    <: &iterate( *events, @DAY )>
    </tr>
    endblock
    
    <: &block( *DAY, 'endblock' )>
    <td class="calendar">
      <div class="calendar">
        <div class="calendarDate">
          <: &iteratorValue( *events, 'monthday' )>
        </div>
    <: &iterate( *events, @HOUR )>
      </div>
    </td>
    endblock
    
    <: &block( *HOUR, 'endblock' )>
    
        <div class="calendarHour"><: &iteratorValue( *events, 'timedisplay' )></div>
    <: &iterate( *events, @EVENT )>
    endblock
    
    <: &block( *EVENT, 'endblock' )>
        <div class="calendarEvent"><: &iteratorValue( *events,'event' )></div>
    endblock
    
    <!--: &comment() content starts here -->
    <table class="calendar" cellspacing="0">
      <tr>
        <td colspan="7" class="monthName">
          <: &iteratorValue( *active, 'monthname' )>
          <: &iteratorValue( *active, 'year' )>
        </td>
      </tr>
      <tr>
    <: &iterate( *active, @HEADER )>
      </tr>
    
    <: &iterate( *events, @WEEK )>
    </table>

=head1 DESCRIPTION

This code generates an HTML table representing an event calendar.

Here's a quick walkthrough of the Pen code:

C<$festival>, defined in C<festival.pl>, (see L<HTML::Pen::Iterator::Example>) 
is a reference to a four dimensional array.  It's structure is defined as:

    \@weeks -> \@days -> \@times -> \@events -> \%eventobjects

C<$festival> data is represented by the iterator C<*events>, which contains
five weeks.  The first complete week, C<< $festival->[1] >>, is represented

lib/HTML/Pen/Iterator/Example.pod  view on Meta::CPAN

# Below is stub documentation for your module. You'd better edit it!

=head1 NAME

HTML::Pen::Iterator - Creating a calendar using a Pen Iterator

=head1 SYNOPSIS

  $festival = [
          [
            bless( {}, 'empty' ),
            bless( {}, 'empty' ),
            bless( {}, 'empty' ),
            bless( {}, 'empty' ),
            [

lib/HTML/Pen/Iterator/Example.pod  view on Meta::CPAN

chronological list of events.

=list

A reference to a B<data> object.  This object displays its B<monthday>
property and does not recurse.

=list

A reference to an B<empty> object.  This object returns no properties
when referenced by C<iteratorValue()>, resulting in empty calendar boxes.

C<iteratorValue()> is type safe, so these objects could be undefined 
scalars instead.

=back

When a days element is represented by an array reference containing a 
nested set of B<event> objects, each B<event> object contains a duplicate 
of the B<date> object to reflect properties normally associated with days 
and times objects.  As arrays, those objects cannot reflect themselves.



( run in 0.300 second using v1.01-cache-2.11-cpan-5dc5da66d9d )