[Jifty-commit] r3831 - in Template-Declare: t
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Thu Aug 9 05:34:54 EDT 2007
Author: agentz
Date: Thu Aug 9 05:34:08 2007
New Revision: 3831
Modified:
Template-Declare/lib/Template/Declare/Tags.pm
Template-Declare/t/tagset_xul.t
Log:
TD - implemented sub xml_decl and we can use it like this: xml_decl { 'xml', version=>'1.0' };
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 05:34:08 2007
@@ -13,7 +13,8 @@
@EXPORT
= qw( with template private show show_page attr outs
- outs_raw in_isolation $self under get_current_attr
+ outs_raw in_isolation $self under
+ get_current_attr xml_decl
smart_tag_wrapper current_template );
our %ATTRIBUTES = ();
@@ -169,6 +170,35 @@
return @_;
}
+=head2 xml_decl HASH
+
+Emits XML declarators.
+
+For example,
+
+ xml_decl { 'xml', version => '1.0' };
+ xml_decl { 'xml-stylesheet', href => "chrome://global/skin/", type => "text/css" };
+
+will produce
+
+ <?xml version="1.0"?>
+ <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+
+=cut
+
+sub xml_decl (&;$) {
+ my $code = shift;
+ my @rv = $code->();
+ my $name = shift @rv;
+ outs_raw("<?$name");
+ while ( my ( $field, $val ) = splice( @rv, 0, 2 ) ) {
+ # only defined whle in a tag context
+ outs_raw(qq/ $field="$val"/);
+ }
+ outs_raw("?>\n");
+ return @_;
+}
+
=head2 outs STUFF
C<outs> HTML-encodes its arguments and appends them to C<Template::Declare>'s output buffer.
Modified: Template-Declare/t/tagset_xul.t
==============================================================================
--- Template-Declare/t/tagset_xul.t (original)
+++ Template-Declare/t/tagset_xul.t Thu Aug 9 05:34:08 2007
@@ -7,6 +7,8 @@
use Template::Declare::Tags qw/ XUL::TagSet /;
template main => sub {
+ xml_decl { 'xml', version => '1.0' };
+ xml_decl { 'xml-stylesheet', href => "chrome://global/skin/", type => "text/css" };
groupbox {
caption { attr { label => 'Colors' } }
radiogroup {
@@ -22,6 +24,8 @@
Template::Declare->init( roots => ['MyApp::Templates']);
my $out = Template::Declare->show('main') . "\n";
is $out, <<_EOC_;
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<groupbox>
<caption label="Colors" />
More information about the Jifty-commit
mailing list