Statocles
view release on metacpan or search on metacpan
lib/Statocles/Document.pm view on Meta::CPAN
#pod See the L<Statocles::Image|Statocles::Image> documentation for a full
#pod list of supported attributes. The most common attributes are:
#pod
#pod =over 4
#pod
#pod =item src
#pod
#pod The source path of the image. Relative paths will be resolved relative
#pod to this document.
#pod
#pod =item alt
#pod
#pod The alternative text to display if the image cannot be downloaded or
#pod rendered. Also the text to use for non-visual media.
#pod
#pod =back
#pod
#pod =cut
#pod =attr date
#pod
#pod ---
#pod date: 2015-03-27
#pod date: 2015-03-27 12:04:00
#pod ---
#pod
#pod The date/time this document is for. For pages, this is the last modified date.
#pod For blog posts, this is the post's date.
#pod
#pod Should be in C<YYYY-MM-DD> or C<YYYY-MM-DD HH:MM:SS> format.
#pod
#pod =cut
has date => (
is => 'rw',
isa => DateTimeObj,
coerce => DateTimeObj->coercion,
predicate => 'has_date',
);
#pod =attr template
#pod
#pod ---
#pod template: /blog/recipe.html
#pod ---
#pod
#pod The path to a template override for this document. If set, the L<document
#pod page|Statocles::Page::Document> will use this instead of the template provided
#pod by the application.
#pod
#pod The template path should not have the final extention (by default C<.ep>).
#pod Different template parsers will have different extentions.
#pod
#pod =cut
has template => (
is => 'rw',
isa => Maybe[ArrayRef[Str]],
coerce => sub {
return $_[0] if ref $_[0];
return [ grep { $_ ne '' } split m{/}, $_[0] ];
},
predicate => 'has_template',
);
#pod =attr layout
#pod
#pod ---
#pod layout: /site/layout-dark.html
#pod ---
#pod
#pod The path to a layout template override for this document. If set, the L<document
#pod page|Statocles::Page::Document> will use this instead of the layout provided
#pod by the application.
#pod
#pod The template path should not have the final extention (by default C<.ep>).
#pod Different template parsers will have different extentions.
#pod
#pod =cut
has layout => (
is => 'rw',
isa => Maybe[ArrayRef[Str]],
coerce => sub {
return $_[0] if ref $_[0];
return [ grep { $_ ne '' } split m{/}, $_[0] ];
},
predicate => 'has_layout',
);
#pod =attr data
#pod
#pod ---
#pod data:
#pod ingredients:
#pod - Eggs
#pod - Milk
#pod - Cheese
#pod ---
#pod % for my $item ( @{ $self->data->{ingredients} } ) {
#pod <%= $item %>
#pod % }
#pod
#pod A hash of extra data to attach to this document. This is available
#pod immediately in the document content, and later in the page template.
#pod
#pod Every document's content is parsed as a template. The C<data> attribute can be
#pod used in the template to allow for some structured data that would be cumbersome
#pod to have to mark up time and again.
#pod
#pod =cut
has data => (
is => 'rw',
);
#pod =attr disable_content_template
#pod
#pod ---
#pod disable_content_template: true
#pod ---
#pod
#pod This disables processing the content as a template. This can speed up processing
#pod when the content is not using template directives.
#pod
#pod This can be also set in the application
#pod (L<Statocles::App/disable_content_template>), or for the entire site
#pod (L<Statocles::Site/disable_content_template>).
#pod
#pod =cut
has disable_content_template => (
is => 'ro',
isa => Bool,
lazy => 1,
default => 0,
predicate => 'has_disable_content_template',
);
around BUILDARGS => sub {
my ( $orig, $self, @args ) = @_;
my $args = $self->$orig( @args );
if ( defined $args->{data} && ref $args->{data} ne 'HASH' ) {
derp qq{Invalid data attribute in document "%s". Data attributes that are not hashes are deprecated and will be removed in v2.0. Please use a hash instead.},
$args->{path};
}
( run in 0.872 second using v1.01-cache-2.11-cpan-5511b514fd6 )