The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Plift::Context - Template data and instructions to be rendered.

SYNOPSIS

    use Plift;

    my $plift = Plift->new(
        path    => \@paths,                               # default ['.']
        plugins => [qw/ Script Blog Gallery GoogleMap /], # plugins not included
    );

    my $tpl = $plift->template("index");

    # set render directives
    $tpl->at({
        '#name' => 'fullname',
        '#contact' => [
            '.phone' => 'contact.phone',
            '.email' => 'contact.email'
        ]
    });

    # render render with data
    my $document = $tpl->render({

        fullname => 'Carlos Fernando Avila Gratz',
        contact => {
            phone => '+55 27 1234-5678',
            email => 'cafe@example.com'
        }
    });

METHODS

at

Adds on or more render directives.

set

Set data to be rendered.

get

Get data via a dotted data-point string.

    $context->set(posts => [
        { title => 'Post 01',  ... },
        { title => 'Post 02',  ... },
        { title => 'Post 03',  ... },
        ...
    ]);

    print $context->get('posts.0.title'); # Post 01

render

Renders the template. Returns a XML::LibXML::jQuery object containing the XML::LibXML::Document node.

    print $context->render(\%data)->as_html;

LICENSE

Copyright (C) Carlos Fernando Avila Gratz.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

Carlos Fernando Avila Gratz <cafe@kreato.com.br>