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 $_ ? $$_ : $_;
78 ( / )? ( [^/!<>\s"'=]+ )
79 ( (?:"[^"]*"|'[^']*'|[^"'<>])+? )?
81 (!-- .*? -- | ![^\-] .*? )
87 my ($whole, $is_close, $tag_name, $attrs, $comment_or_directive,
88 $in_place_close) = @info;
90 if($comment_or_directive) {
91 +{ type => 'SPECIAL', raw => $raw };
92 } elsif(!scalar(@info)) {
93 +{ type => 'TEXT', raw => $raw };
96 $tag_name =~ tr/A-Z/a-z/;
97 +{ type => 'CLOSE', name => $tag_name, raw => $raw};
99 $attrs = '' if !defined($attrs) or $attrs =~ /^ +$/;
103 is_in_place_close => $in_place_close,
104 HTML::Zoom::Parser::BuiltIn::_hacky_attribute_parser($attrs),
105 raw_attrs => $attrs||'',
112 is_in_place_close => 1,
121 ok my $html = BasicPage->show_landing_html;
122 ok my $zoom = HTML::Zoom->from_html($html);
123 ok my $events = BasicPage->show_landing_events;
125 use Data::Dump 'dump';
127 warn dump $zoom->to_events;