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

NAME

DbFramework::Template - Fill template with database values

SYNOPSIS

  use DbFramework::Template;
  $t = new DbFramework::Template($template,\@tables);
  print $t->fill;
  $t->default($table);
  $t->template->set_text($template);

DESCRIPTION

DbFramework::Template is a class for filling templates with values from a database.

Template placeholders

The following list describes the placeholders allowed in a template. In each case %values relates to the hash passed to the fill() method.

(:&db_value(table.column):)

Replaced with the value from %values whose key is table.column. See "table_qualified_attribute_hashref()" in DbFramework::Persistent for a useful method for generating a hash to fill this type of placeholder.

(:&db_html_form_field(table.column[ value=value][ type=type]):)

Replaced with an HTML form field appropriate for the column column in the table table. value is the inital value which will be applied to the field. The type of field generated is determined by the data type of column. This can be overridden by setting type. See "as_html_form_field()" in DbFramework::Attribute for more details.

(:&db_fk_html_form_field(table.fk):)

Replaced with an HTML form field appropriate for the foreign key fk in the table table. See "as_html_form_field()" in DbFramework::ForeignKey for more details.

SUPERCLASSES

DbFramework::Util

CLASS METHODS

new($template,\@tables)

Create a new DbFramework::Template object. $template is the template to be filled. @tables are the DbFramework::Table objects required for filling the template.

OBJECT METHODS

template()

Returns the Text::FillIn object associated with the template.

fill(\%values)

Returns a filled template. The values in %values are used to fill certain placeholders in the template (see "Template placeholders".)

default($table)

$table is a DbFramework::Table object. Sets up a default template consisting of all fields in $table.

SEE ALSO

Text::FillIn and DbFramework::Util.

AUTHOR

Paul Sharpe <paul@miraclefish.com>

COPYRIGHT

Copyright (c) 1999 Paul Sharpe. England. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.