Contenticious

 view release on metacpan or  search on metacpan

lib/Contenticious.pm  view on Meta::CPAN

<h1><%= $content_node->title %></h1>
<ul id="content_list">
% foreach my $c (@{$content_node->children}) {
    % my $url = rel_url_for 'content', cpath => $c->path, format => 'html';
    <li><a href="<%= $url %>"><strong><%= $c->title %></strong></a></li>
% }
</ul>

@@ navi.html.ep
% my $node      = contenticious->root_node;
% my @names     = split m|/| => $cpath;
% my $level     = 1;
% LOOP: { do { # perldoc perlsyn: do-while isn't a loop
    % last unless $node->can('children');
    % my $name      = shift(@names) // '';
    % my $id_prefix = 'sub' x ($level - 1);
    % unless (
    %   (defined stash('only') and stash('only') != $level) or
    %   (defined stash('only_not') and stash('only_not') == $level)
    % ) {
    <ul class="navi" id="<%= $id_prefix %>navi">

lib/Contenticious/Content.pm  view on Meta::CPAN

        is_root     => 1,
    );
}

# find a content node for a given path like foo/bar/baz
sub find {
    my $self = shift;
    my $path = shift // '';

    # split path and find content node
    my @names = split m|/| => $path;
    return $self->root_node->find(@names);
}

# execute a subroutine for all content nodes
# the given subroutine gets the node as a single argument
sub for_all_nodes {
    my ($self, $sub) = @_;
    _walk_tree($self->root_node, $sub);
}



( run in 0.894 second using v1.01-cache-2.11-cpan-71847e10f99 )