preaction / Statocles

Static website CMS
http://preaction.me/statocles
Other
84 stars 33 forks source link

Page sections method should allow indexes #490

Closed preaction closed 8 years ago

preaction commented 8 years ago

We should be able to pass in the index of the section we want and get only that section, or multiple sections. This makes it easier to split up the blog sections. In scalar context, should return the number of sections.

Where right now we must:

% my @sections = $page->section;
% for my $i ( 0..$#sections ) {
    <section id="section-<%= $i %>">
        <%= $sections[ $i ] %>
    </section>
% }

With this change we can:

% for my $i ( 0 .. $page->sections ) {
    <section id="section-<%= $i %>">
        <%= $page->sections( $i ) %>
    </section>
% }

This is helpful when making links to sections, and seems easier to understand to me.