Bob Glickstein > Blatte-0.9.4 > Blatte::Compiler

Download:
Blatte-0.9.4.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

Blatte::Compiler - compile a Blatte document into Perl

SYNOPSIS ^

    use Blatte::Compiler;

    &Blatte::Compiler::compile($file_handle, \&callback);

    &Blatte::Compiler::compile_sparse($file_handle, \&callback);

    sub callback {
      my($val, $src) = @_;

      if (defined($src)) {
        ...Blatte expression...
      } else {
        ...plain text...
      }
    }

DESCRIPTION ^

This is a convenient interface for parsing a file full of Blatte code. A file handle and a callback are passed to compile() or compile_sparse() (see below for the difference between the two). The callback is then invoked for each top-level item parsed from the input.

The compile() function treats its entire input as a sequence of Blatte expressions, including plain text at the top level, which is divided up into Blatte "words," each of which is one Blatte expression. The callback is called once for each expression, with two arguments: the Perl string resulting from parsing the Blatte expression; and the Blatte source string itself.

The compile_sparse() function works the same way, except that plain text at the top-level of the input is not divided into words. Only Blatte expressions beginning with a Blatte metacharacter are parsed as described above. All text in between such expressions is passed as a single string to the callback, with no second argument.

AUTHOR ^

Bob Glickstein <bobg@zanshin.com>.

Visit the Blatte website, <http://www.blatte.org/>.

LICENSE ^

Copyright 2001 Bob Glickstein. All rights reserved.

Blatte is distributed under the terms of the GNU General Public License, version 2. See the file LICENSE that accompanies the Blatte distribution.

SEE ALSO ^

Blatte(3), blatte(1).

syntax highlighting: