2 use warnings FATAL => 'all';
10 sub show_landing_html {
12 title => "Welcome to the Demo Home",
14 new_user_link => 'create_user.html',
18 sub show_landing_events {
19 as_events(\&landing, (
20 title => "Welcome to the Demo Home",
22 new_user_link => 'create_user.html',
28 \'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
31 <!-- here is a comment -->,
32 <title>, ($data{title} || 'Hello World'), </title>,
42 <p>, "Hi, I'm version: $data{site_version}", </p>,
43 <p>, "Here's some interesting things about me", </p>,
44 <img src="smilyface.png" alt="smiles" />,
46 <li>, <a href="/user">, "My Users", </li>,
47 <li>, <a href="/user/$data{new_user_link}">, "Create New User", </li>,
51 sub process_templates {
52 my ($templates, %data) = @_;
53 for my $template(@$templates) {
54 my @processed = $template->(%data);
55 $data{content} = \@processed;
57 return @{$data{content}};
61 my ($template, %data) = @_;
62 my @content = process_templates([$template, \&layout], %data);
63 return join '', HTML::Tags::to_html_string(@content);
67 my ($template, %data) = @_;
68 my @content = process_templates([$template, \&layout], %data);
69 return [_convert_to_events(@content)];
72 sub _convert_to_events {
74 my $raw = ref $_ ? (ref $_ eq 'SCALAR' ? $$_: "$_") : $_;
79 ( / )? ( [^/!<>\s"'=]+ )
80 ( (?:"[^"]*"|'[^']*'|[^"'<>])+? )?
82 (!-- .*? -- | ![^\-] .*? )
94 $comment_or_directive,
98 if($comment_or_directive) {
99 +{ type => 'SPECIAL', raw => $raw };
100 } elsif(!scalar(@info)) {
101 +{ type => 'TEXT', raw => $raw };
104 $tag_name =~ tr/A-Z/a-z/;
105 +{ type => 'CLOSE', name => $tag_name, raw => $raw};
107 $attrs = '' if !defined($attrs) or $attrs =~ /^ +$/;
111 is_in_place_close => $in_place_close,
112 HTML::Zoom::Parser::BuiltIn::_hacky_attribute_parser($attrs),
113 raw_attrs => $attrs||'',
120 is_in_place_close => 1,
129 ok my $html = BasicPage->show_landing_html;
130 ok my $zoom = HTML::Zoom->from_html($html);
131 ok my $events = BasicPage->show_landing_events;
133 is_deeply $zoom->to_events, $events,
134 'Made HZoom events from XMLTags';
136 #use Data::Dump 'dump';
138 #warn dump $zoom->to_events;