[Jifty-commit] r3829 - in Template-Declare: lib/Template/Declare t
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Thu Aug 9 03:13:28 EDT 2007
Author: agentz
Date: Thu Aug 9 03:13:28 2007
New Revision: 3829
Modified:
Template-Declare/lib/Template/Declare.pm
Template-Declare/lib/Template/Declare/Tags.pm
Template-Declare/t/alternative.t
Template-Declare/t/tagset_html.t
Template-Declare/t/tagset_mix.t
Template-Declare/t/tagset_xul.t
Log:
[TD]
* implemented the "XXX" TODO in Template::Declare::Tags and it now uses $tagset->can_combine_empty_tags.
* updated the XUL tests accordingly.
* exchanged tagset_xul and tagset_mix.t.
Modified: Template-Declare/lib/Template/Declare.pm
==============================================================================
--- Template-Declare/lib/Template/Declare.pm (original)
+++ Template-Declare/lib/Template/Declare.pm Thu Aug 9 03:13:28 2007
@@ -64,7 +64,7 @@
=head2 Basic usage
package MyApp::Templates;
- use Template::Declare::Tags;
+ use Template::Declare::Tags 'HTML::Tags';
use base 'Template::Declare';
template simple => sub {
Modified: Template-Declare/lib/Template/Declare/Tags.pm
==============================================================================
--- Template-Declare/lib/Template/Declare/Tags.pm (original)
+++ Template-Declare/lib/Template/Declare/Tags.pm Thu Aug 9 03:13:28 2007
@@ -12,7 +12,9 @@
use Symbol 'qualify_to_ref';
@EXPORT
- = qw( with template private show show_page attr outs outs_raw in_isolation $self under get_current_attr smart_tag_wrapper current_template );
+ = qw( with template private show show_page attr outs
+ outs_raw in_isolation $self under get_current_attr
+ smart_tag_wrapper current_template );
our %ATTRIBUTES = ();
our %ELEMENT_ID_CACHE = ();
@@ -63,7 +65,7 @@
=head1 DESCRIPTION
-Template::Declare::Tags is used to generate and export
+C<Template::Declare::Tags> is used to generate and export
subroutines for tags into the user's namespace.
You can specify the tag sets used by providing a list of
@@ -71,7 +73,7 @@
use Template::Declare::Tags qw/ HTML::TagSet XUL::TagSet/;
-By default, it uses the tag set provided by C<HTML::TagSet>. So
+By default, it uses the tag set provided by L<HTML::TagSet>. So
use Template::Declare::Tags;
@@ -79,25 +81,11 @@
use Template::Declare::Tags 'HTML::TagSet';
-Currently C<Template::Declare> bundles C<HTML::TagSet>
-for HTML tags and C<XUL::TagSet> for XUL tags. You can
+Currently L<Template::Declare> bundles L<HTML::TagSet>
+for HTML tags and L<XUL::TagSet> for XUL tags. You can
certainly specify your own tag set classes, as long
-as they implement a C<tags> method which returns
-a hash ref. The keys of the hash ref are the names
-for your custom tags and the values are also hash refs,
-which are the options for the corresponding tag.
-An example is as follows:
-
- {
- html => {},
- body => {},
- tr => { alternate => 'row' },
- td => { alternate => 'cell' },
- }
-
-The 'alternate' option is used to specify an
-alternative spelling for the correspondig tag
-if there's a naming conflict.
+as they subclass L<Template::Declare::TagSet> and implement
+the corresponding methods (e.g. C<get_tag_list>).
=head1 METHODS
@@ -111,7 +99,6 @@
(Did you know that you can have characters like ":" and "/" in your Perl
subroutine names? The easy way to get at them is with "can").
-
=cut
sub template ($$) {
@@ -130,8 +117,7 @@
};
if (wantarray) {
-
-# We're being called by something like private that doesn't want us to register ourselves
+ # We're being called by something like private that doesn't want us to register ourselves
return ( $template_class, $template_name, $codesub );
} else {
@@ -283,12 +269,12 @@
my $sub = sub {
local $self = $_self;
local *__ANON__ = $tag;
- _tag(@__);
+ _tag($tagset, @__);
};
bless $sub, 'Template::Declare::Tag';
return $sub;
} else {
- _tag(@_);
+ _tag($tagset, @_);
}
};
}
@@ -384,6 +370,7 @@
}
sub _tag {
+ my $tagset = shift;
my $code = shift;
my $more_code = shift;
my ($package, $filename, $line, $subroutine, $hasargs,
@@ -456,16 +443,9 @@
if ($had_content) {
$buf .= "\n" . ( " " x $TAG_NEST_DEPTH ) if ( $buf =~ /\>$/ );
$buf .= "</$tag>";
- } elsif ( $tag
- =~ m{\A(?: base | meta | link | hr | br | param | img | area | input | col )\z}x
- )
- {
-
- # XXX TODO: This should come out of HTML::Tagset
- # EMPTY tags can close themselves.
+ } elsif ( $tagset->can_combine_empty_tags($tag)) {
$buf .= " />";
} else {
-
# Otherwise we supply a closing tag.
$buf .= "></$tag>";
}
Modified: Template-Declare/t/alternative.t
==============================================================================
--- Template-Declare/t/alternative.t (original)
+++ Template-Declare/t/alternative.t Thu Aug 9 03:13:28 2007
@@ -27,6 +27,6 @@
my $out = Template::Declare->show('main') . "\n";
::is $out, <<_EOC_;
-<template></template>
+<template />
_EOC_
Modified: Template-Declare/t/tagset_html.t
==============================================================================
--- Template-Declare/t/tagset_html.t (original)
+++ Template-Declare/t/tagset_html.t Thu Aug 9 03:13:28 2007
@@ -12,6 +12,8 @@
cell { "Hello, world!" }
}
}
+ img { attr { src => 'cat.gif' } }
+ label {}
};
package main;
@@ -25,5 +27,7 @@
<td>Hello, world!</td>
</tr>
</table>
+<img src="cat.gif" />
+<label></label>
_EOC_
Modified: Template-Declare/t/tagset_mix.t
==============================================================================
--- Template-Declare/t/tagset_mix.t (original)
+++ Template-Declare/t/tagset_mix.t Thu Aug 9 03:13:28 2007
@@ -4,7 +4,7 @@
package MyApp::Templates;
use base 'Template::Declare';
-use Template::Declare::Tags qw/ XUL::TagSet /;
+use Template::Declare::Tags qw/ HTML::TagSet XUL::TagSet /;
template main => sub {
groupbox {
@@ -14,6 +14,9 @@
radio { attr { id => $id, label => ucfirst($id), $id eq 'violet' ? (selected => 'true') : () } }
}
}
+ html {
+ body { p { 'hi' } }
+ }
}
};
@@ -24,12 +27,17 @@
is $out, <<_EOC_;
<groupbox>
- <caption label="Colors"></caption>
+ <caption label="Colors" />
<radiogroup>
- <radio id="orange" label="Orange"></radio>
- <radio id="violet" label="Violet" selected="true"></radio>
- <radio id="yellow" label="Yellow"></radio>
+ <radio id="orange" label="Orange" />
+ <radio id="violet" label="Violet" selected="true" />
+ <radio id="yellow" label="Yellow" />
</radiogroup>
+ <html>
+ <body>
+ <p>hi</p>
+ </body>
+ </html>
</groupbox>
_EOC_
Modified: Template-Declare/t/tagset_xul.t
==============================================================================
--- Template-Declare/t/tagset_xul.t (original)
+++ Template-Declare/t/tagset_xul.t Thu Aug 9 03:13:28 2007
@@ -4,7 +4,7 @@
package MyApp::Templates;
use base 'Template::Declare';
-use Template::Declare::Tags qw/ HTML::TagSet XUL::TagSet /;
+use Template::Declare::Tags qw/ XUL::TagSet /;
template main => sub {
groupbox {
@@ -14,9 +14,6 @@
radio { attr { id => $id, label => ucfirst($id), $id eq 'violet' ? (selected => 'true') : () } }
}
}
- html {
- body { p { 'hi' } }
- }
}
};
@@ -27,17 +24,12 @@
is $out, <<_EOC_;
<groupbox>
- <caption label="Colors"></caption>
+ <caption label="Colors" />
<radiogroup>
- <radio id="orange" label="Orange"></radio>
- <radio id="violet" label="Violet" selected="true"></radio>
- <radio id="yellow" label="Yellow"></radio>
+ <radio id="orange" label="Orange" />
+ <radio id="violet" label="Violet" selected="true" />
+ <radio id="yellow" label="Yellow" />
</radiogroup>
- <html>
- <body>
- <p>hi</p>
- </body>
- </html>
</groupbox>
_EOC_
More information about the Jifty-commit
mailing list