[LWN Logo]

From: ken@forum.swarthmore.edu (Ken Williams)
Subject: ANNOUNCE: Text::FillIn.pm (new)
Date: 31 Mar 1998 23:34:27 GMT

Hi,

I've just uploaded a new module, Text::FillIn.pm version 0.01, to CPAN. 
It is a class for implementing fill-in text templates.  It is designed to
be flexible and sub-classible.  It can handle tags inside other tags.

SYNOPSIS

   use Text::FillIn;

   $template = new Text::FillIn('some text with [[$vars]] and [[&routines]]');
   $filled_in = $template->interpret();  # Returns filled-in template

   $template->interpret_and_print();  # Prints template to currently 
                                      # selected filehandle, streaming output

   # Set parsing options:
   $Text::FillIn::HOOK{'$'} = sub { return ${$_[0]} };  # Hard reference
   $Text::FillIn::HOOK{'&'} = "main::run_function";     # Symbolic reference
   sub run_function { return &{$_[0]} }

   # Nested templates
   $template = new Text::FillIn();
   $template->set_text('the text is [[ $[[$var1]][[$var2]] ]]');
   $var1 = 'two_';
   $var2 = 'parter';
   $two_parter = 'interpreted';
   $template->interpret_and_print();  # Prints "the text is interpreted"


   $template = new Text::FillIn();
   $template->get_file('/etc/template_dir/my_template');  # Fetches a file


   $template = new Text::FillIn();
   @Text::FillIn::TEMPLATE_PATH = 
      ('.', '/etc/template_dir');  # Where to find templates
   $template->get_file('my_template'); # Gets ./my_template or 
                                       # /etc/template_dir/my_template


For more specific information, please see the documentation inside
FillIn.pm, by doing "pod2txt FillIn.pm", or "perldoc Text::FillIn" once
you've installed the module.

> 
>   file: $CPAN/authors/id/KWILLIAMS/Text-FillIn-0.01.tar.gz
>   size: 11921 bytes
>    md5: fcd15d853783f34959fb8a89e068f5d7