package Blosxom::Plugin::DataSection; use strict; use warnings; use Data::Section::Simple; my @exports = qw( get_data_section merge_data_section_into ); sub init { my ( $class, $caller ) = @_; $caller->add_attribute( data_section => \&_build_data_section ); $caller->add_method( $_ => \&{$_} ) for @exports; return; } sub _build_data_section { Data::Section::Simple->new($_[0])->get_data_section; } sub get_data_section { $_[0]->data_section->{$_[1]} } sub merge_data_section_into { my ( $pkg, $merge_into ) = @_; my $data_section = $pkg->data_section; for my $name ( keys %{$data_section} ) { my ( $chunk, $flavour ) = $name =~ /(.*)\.([^.]*)/; $merge_into->{ $flavour }{ $chunk } = $data_section->{ $name }; } } 1; __END__ =head1 NAME Blosxom::Plugin::DataSection - Read data from __DATA__ =head1 SYNOPSIS package my_plugin; use strict; use warnings; use parent 'Blosxom::Plguin'; __PACKAGE__->load_components( 'DataSection' ); sub start { my $class = shift; my $template = $class->get_data_section( 'my_plugin.html' ); # # ... # merge __DATA__ into Blosxom default templates $class->merge_data_section_into( \%blosxom::template ); return 1; } 1; __DATA__ @@ my_plugin.html My Plugin

Hello, world

=head1 DESCRIPTION This module extracts data from C<__DATA__> section of the plugin, and also merges them into Blosxom default templates. =head2 METHODS =over 4 =item $template = $class->get_data_section( $name ) This method returns a string containing the data from the named section. =item $class->merge_data_section_into( \%blosxom::template ) Given a reference to a hash which holds Blosxom default templates, merges __DATA__ into the hash. The following data structure is expected: { html => { head => '...', story => '

...', }, rss => { head => '...', story => '...', }, } =back =head1 SEE ALSO L, L =head1 AUTHOR Ryo Anazawa =head1 LICENSE This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L. =cut