__END__ =pod =head1 NAME Text::APL - non-blocking and streaming capable template engine =head1 SYNOPSIS =head2 Simple example $template->render( input => \$input, output => \$output, vars => {foo => 'bar'} ); =head2 Streaming example $template->render( input => sub { my ($cb) = @_; # Call $cb($data) when data is available # Call $cb->() on EOF }, output => sub { my ($chunk) = @_; # Print $chunk to the needed output # $chunk is undef when template is fully rendered }, vars => {foo => 'bar'} ); =head1 DESCRIPTION This is yet another template engine. But compared to others it supports non-blocking (read/write) and streaming output. =head2 Reader/Writer Reader and writer can be a subroutine references reading from any source and writing output to any destination. Sane default implementations for reading from a string, a file or file handle and writing to the string, a file or a file handle are also available. =head2 Parser Parser can parse not only full templates but chunk by chunk correctly resolving any ambiguous leftovers. This allows immediate parsing. =head2 Compiler Compiler compiles templates into Perl code but when evaluating does not create a Perl string that accumulates all the template output, but rather provides a special C function that pushes the content as soon as it's available (streaming). The generated Perl code can looks like this: Hello, <%= $nickname %>! # becomes __print(q{Hello, }); __print_escaped(do {$foo}); __print(q{!}); =head1 SYNTAX Syntax is borrowed from the template standards shared among several web framewoks in different languages: <% foo() %> # evaluate code % foo() <%= $foo %> # insert evaluation result %= $foo <%== $foo %> # insert evaluation result without escaping %== %foo No new template language is provided, just the old Perl. =head1 METHODS =head2 C my $template = Text::APL->new; Create new L instance. Accepted options: =over =item * parser (by default L) =item * parser_factory (by default L) =item * translator (by default L) =item * compiler (by default L) =item * reader (by default L) =item * writer (by default L) =back =head2 C $template->render( input => \$input, output => \$output, vars => {foo => 'bar'}, helpers => { time => sub {time} } ); C and C can be a filename, a reference to scalar, a file handle and a reference to subroutine. Read more at L and L. C are Perl variables available in the template. C are Perl subroutines. available in the template. =head1 EXAMPLES For working examples see C directory in distribution. =head1 DEVELOPMENT =head2 Repository http://github.com/vti/text-apl =head1 AUTHOR Viacheslav Tykhanovskyi, C. =head1 COPYRIGHT AND LICENSE Copyright (C) 2012, Viacheslav Tykhanovskyi This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0. =cut