[Jifty-commit] r4054 - in Template-Declare: lib/Template/Declare lib/Template/Declare/TagSet/RDF t

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Fri Sep 7 06:35:31 EDT 2007


Author: agentz
Date: Fri Sep  7 06:35:27 2007
New Revision: 4054

Added:
   Template-Declare/lib/Template/Declare/TagSet/RDF/
   Template-Declare/lib/Template/Declare/TagSet/RDF/EM.pm
   Template-Declare/t/tagset_rdf_em.t
Modified:
   Template-Declare/Changes
   Template-Declare/MANIFEST
   Template-Declare/lib/Template/Declare/Tags.pm

Log:
TD - added support for Mozilla's EM RDF tag set (T::D::TagSet::RDF::EM)

Modified: Template-Declare/Changes
==============================================================================
--- Template-Declare/Changes	(original)
+++ Template-Declare/Changes	Fri Sep  7 06:35:27 2007
@@ -1,5 +1,6 @@
 0.27 - XXX
 * Added support for the RDF tag set (T::D::TagSet::RDF).
+* Added support for the Mozilla EM RDF tag set (T::D::TagSet::RDF::EM)
 
 0.26 - 2007-08-14
 * Refactored Template::Declare::Tags to make the tag sets configurable.

Modified: Template-Declare/MANIFEST
==============================================================================
--- Template-Declare/MANIFEST	(original)
+++ Template-Declare/MANIFEST	Fri Sep  7 06:35:27 2007
@@ -13,6 +13,7 @@
 lib/Template/Declare/TagSet.pm
 lib/Template/Declare/TagSet/HTML.pm
 lib/Template/Declare/TagSet/RDF.pm
+lib/Template/Declare/TagSet/RDF/EM.pm
 lib/Template/Declare/TagSet/XUL.pm
 Makefile.PL
 MANIFEST			This list of files
@@ -50,6 +51,7 @@
 t/tagset_html.t
 t/tagset_mix.t
 t/tagset_rdf.t
+t/tagset_rdf_em.t
 t/tagset_xul.t
 t/trivial.t
 t/utf8.t

Added: Template-Declare/lib/Template/Declare/TagSet/RDF/EM.pm
==============================================================================
--- (empty file)
+++ Template-Declare/lib/Template/Declare/TagSet/RDF/EM.pm	Fri Sep  7 06:35:27 2007
@@ -0,0 +1,93 @@
+package Template::Declare::TagSet::RDF::EM;
+
+use strict;
+use warnings;
+use base 'Template::Declare::TagSet';
+#use Smart::Comments;
+
+sub get_tag_list {
+    return [ qw{
+        aboutURL    contributor    creator
+        description    developer    file
+        hidden    homepageURL    iconURL
+        id    locale    localized
+        maxVersion    minVersion    name
+        optionsURL    package    requires
+        skin    targetApplication    targetPlatform
+        translator    type    updateURL
+        version
+    } ];
+}
+
+1;
+__END__
+
+=head1 NAME
+
+Template::Declare::TagSet::RDF::EM - Tag set for Mozilla's em-rdf
+
+=head1 SYNOPSIS
+
+    # normal use on the user side:
+    use base 'Template::Declare';
+    use Template::Declare::Tags
+         'RDF::EM' => { namespace => 'em' }, 'RDF';
+
+    template foo => sub {
+        RDF {
+            attr {
+                'xmlns' => "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
+                'xmlns:em' => 'http://www.mozilla.org/2004/em-rdf#'
+            }
+            Description {
+                attr { about => 'urn:mozilla:install-manifest' }
+                em::id { 'foo at bar.com' }
+                em::version { '1.2.0' }
+                em::type { '2' }
+                em::creator { 'Agent Zhang' }
+            }
+        }
+    };
+
+=head1 INHERITANCE
+
+    Template::Declare::TagSet::RDF::EM
+        isa Template::Declare::TagSet
+
+=head1 METHODS
+
+=over
+
+=item C<< $obj = Template::Declare::TagSet::RDF::EM->new({ namespace => $XML_namespace, package => $Perl_package }) >>
+
+Constructor inherited from L<Template::Declare::TagSet>.
+
+=item C<< $list = $obj->get_tag_list() >>
+
+Returns an array ref for the tag names.
+
+Currently the following tags are supported:
+
+        aboutURL    contributor    creator
+        description    developer    file
+        hidden    homepageURL    iconURL
+        id    locale    localized
+        maxVersion    minVersion    name
+        optionsURL    package    requires
+        skin    targetApplication    targetPlatform
+        translator    type    updateURL
+        version
+
+This list may be not exhaustive; if you find some
+important missing ones, please let us know :)
+
+=back
+
+=head1 AUTHOR
+
+Agent Zhang E<lt>agentzh at gmail.comE<gt>
+
+=head1 SEE ALSO
+
+L<Template::Declare::TagSet>, L<Template::Declare::TagSet::RDF>, L<Template::Declare::TagSet::XUL>, L<Template::Declare::Tags>, L<Template::Declare>.
+

Modified: Template-Declare/lib/Template/Declare/Tags.pm
==============================================================================
--- Template-Declare/lib/Template/Declare/Tags.pm	(original)
+++ Template-Declare/lib/Template/Declare/Tags.pm	Fri Sep  7 06:35:27 2007
@@ -154,8 +154,9 @@
     use Template::Declare::Tags 'HTML';
 
 Currently L<Template::Declare> bundles the following tag sets:
-L<Template::Declare::TagSet::HTML>, L<Template::Declare::TagSet::XUL>, and L<Template::Declare::TagSet::RDF>. You can
-certainly specify your own tag set classes, as long
+L<Template::Declare::TagSet::HTML>, L<Template::Declare::TagSet::XUL>, L<Template::Declare::TagSet::RDF>, and L<Template::Declare::TagSet::RDF::EM>.
+
+You can certainly specify your own tag set classes, as long
 as they subclass L<Template::Declare::TagSet> and implement
 the corresponding methods (e.g. C<get_tag_list>).
 

Added: Template-Declare/t/tagset_rdf_em.t
==============================================================================
--- (empty file)
+++ Template-Declare/t/tagset_rdf_em.t	Fri Sep  7 06:35:27 2007
@@ -0,0 +1,42 @@
+use strict;
+use warnings;
+
+package MyApp::Templates;
+
+use base 'Template::Declare';
+use Template::Declare::Tags
+        'RDF::EM' => { namespace => 'em' }, 'RDF';
+
+template foo => sub {
+    RDF {
+        attr {
+            'xmlns' => "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
+            'xmlns:em' => 'http://www.mozilla.org/2004/em-rdf#'
+        }
+        Description {
+            attr { about => 'urn:mozilla:install-manifest' }
+            em::id { 'foo at bar.com' }
+            em::version { '1.2.0' }
+            em::type { '2' }
+            em::creator { 'Agent Zhang' }
+        }
+    }
+};
+
+package main;
+use Test::More tests => 1;
+
+Template::Declare->init( roots => ['MyApp::Templates']);
+my $out = Template::Declare->show('foo') . "\n";
+is $out, <<'_EOC_';
+
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+ <Description about="urn:mozilla:install-manifest">
+  <em:id>foo at bar.com</em:id>
+  <em:version>1.2.0</em:version>
+  <em:type>2</em:type>
+  <em:creator>Agent Zhang</em:creator>
+ </Description>
+</RDF>
+_EOC_
+


More information about the Jifty-commit mailing list