DbFramework::Template - Fill template with database values


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 the DbFramework::Persistent manpage 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 the DbFramework::Attribute manpage 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 the DbFramework::ForeignKey manpage 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

the Text::FillIn manpage and the DbFramework::Util manpage.


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.

 DbFramework::Template - Fill template with database values