#------------------------------------------------------------------------------ # DBO::Visitor::RenderHTML - render record as HTML # # DESCRIPTION # A visitor class that renders a record as HTML. # # AUTHOR # Gareth Rees # # COPYRIGHT # Copyright (c) 1999 Canon Research Centre Europe Ltd/ # # $Id$ #------------------------------------------------------------------------------ use strict; package DBO::Visitor::RenderHTML; use base qw(DBO::Visitor); use Class::Multimethods; use HTML::FromText 'text2html'; multimethod visit_table => qw(DBO::Visitor::RenderHTML DBO::Table DBO::Handle) => sub { my ($vis, $table, $handle) = @_; my @html = ("
\n"); $vis->{html} = \@html; # visit_table(superclass($vis), $table, $handle); call_next_method(); push @html, "
\n"; join '', @html; }; multimethod visit_column => qw(DBO::Visitor::RenderHTML DBO::Column::String DBO::Handle) => sub { my ($vis, $col, $handle) = @_; my $name = defined $col->{print_name} ? $col->{print_name} : $col->{name}; my $value = $vis->{record}{$col->{name}}; push @{$vis->{html}}, ("", text2html($name), "\n", text2html($value), "\n") if defined $value; }; multimethod visit_column => qw(DBO::Visitor::RenderHTML DBO::Column::Number DBO::Handle) => sub { my ($vis, $col, $handle) = @_; my $name = defined $col->{print_name} ? $col->{print_name} : $col->{name}; my $value = $vis->{record}{$col->{name}}; push @{$vis->{html}}, ("", text2html($name), "\n", $vis->{record}{$col->{name}}, "\n") if defined $value; }; 1;