#============================================================= -*-perl-*- # # t/domview.t # # Test the XML::DOM plugin presenting via a VIEW # # Written by Andy Wardley # # Copyright (C) 1996-2001 Andy Wardley. All Rights Reserved. # Copyright (C) 1998-2001 Canon Research Centre Europe Ltd. # # This is free software; you can redistribute it and/or modify it # under the same terms as Perl itself. # # $Id: domview.t,v 2.3 2002/08/12 11:07:14 abw Exp $ # #======================================================================== use strict; use lib qw( ./lib ../lib ); use Template; use Template::Test; use Cwd qw( abs_path ); $^W = 1; #$Template::Test::DEBUG = 1; #$Template::Test::PRESERVE = 1; # I hate having to do this my $shut_up_warnings = $XML::DOM::VERSION; eval "use XML::DOM"; if ($@ || $XML::DOM::VERSION < 1.27) { skip_all("XML::DOM v1.27 or later not installed"); } test_expect(\*DATA); __END__ -- test -- [% xmltext = BLOCK -%]

Blah blah.

  • Item 1
  • item 2

...
[% END -%] [% USE dom = XML.DOM; doc = dom.parse(text => xmltext); report = doc.getElementsByTagName('report') -%] [% VIEW report_view notfound='xmlstring' %] # handler block for a ... element [% BLOCK report; item.content(view); END %] # handler block for a
...
element [% BLOCK section -%]

[% item.title %]

[% item.content(view) -%] [% END -%] # default template block converts item to string representation [% BLOCK xmlstring; item.toString; END %] # block to generate simple text [% BLOCK text; item; END %] [% END -%] REPORT: [% report_view.print(report) | trim %] -- expect -- REPORT:

Introduction

Blah blah.

The Gory Details

...