petal include: modifier

Warren Smith <wsmith-KfBRzk3UKwrYd54FQh9/[email protected]>
Newsgroups gmane.comp.lang.perl.modules.petal
Message-ID <[email protected]>
This is very simple, and allows you to do something like this

given {
	template => 'content.html'
}
you can do

<html>
<div petal:content="structure include: ${template}" />
</html>

and content.html will be included in your main site.

And as everybody knows, there is always more than one way to do it, but
this worked for me.


package Petal::Hash::Include;

use strict;
use warnings;

use base qw/Petal::Hash::String/;

sub process {
    my ($self, $hash, $args) = @_;

    my $fn = $self->SUPER::process($hash, $args);
    my $tpl = Petal->new($fn);
    return $tpl->process($hash);
}

1;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.