[Jifty-commit] r3867 - Template-Declare/lib/Template
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Sun Aug 12 22:38:44 EDT 2007
Author: agentz
Date: Sun Aug 12 22:38:44 2007
New Revision: 3867
Modified:
Template-Declare/lib/Template/Declare.pm
Log:
TD
* improved the POD in Template::Declare (thanks Eidolos++ for catching a bug in the doc).
Modified: Template-Declare/lib/Template/Declare.pm
==============================================================================
--- Template-Declare/lib/Template/Declare.pm (original)
+++ Template-Declare/lib/Template/Declare.pm Sun Aug 12 22:38:44 2007
@@ -65,35 +65,82 @@
=head2 Basic usage
- package MyApp::Templates;
- use Template::Declare::Tags 'HTML::Tags';
- use base 'Template::Declare';
+ ##############################
+ # Basic HTML usage:
+ ###############################
+ package MyApp::Templates;
+ use Template::Declare::Tags; # defaults to 'HTML'
+ use base 'Template::Declare';
+
+ template simple => sub {
+ html {
+ head {}
+ body {
+ p {'Hello, world wide web!'};
+ }
+ }
+ };
- template simple => sub {
- html {
- head {}
- body {
- p {'Hello, world wide web!'};
+ package main;
+ use Template::Declare;
+ Template::Declare->init( roots => ['MyApp::Templates']);
+ print Template::Declare->show( 'simple');
+
+ # Output:
+ #
+ #
+ # <html>
+ # <head></head>
+ # <body>
+ # <p>Hello, world wide web!
+ # </p>
+ # </body>
+ # </html>
+
+ ###############################
+ # Let's do XUL!
+ ###############################
+ package MyApp::Templates;
+ use base 'Template::Declare';
+ use Template::Declare::Tags 'XUL';
+
+ 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 {
+ for my $id ( qw< orange violet yellow > ) {
+ radio {
+ attr {
+ id => $id,
+ label => ucfirst($id),
+ $id eq 'violet' ?
+ (selected => 'true') : ()
+ }
+ }
+ } # for
}
}
- };
-
- package main;
- use Template::Declare;
- Template::Declare->init( roots => ['MyApp::Templates']);
- print Template::Declare->show( 'simple');
-
- # Output:
- #
- #
- # <html>
- # <head></head>
- # <body>
- # <p>Hello, world wide web!
- # </p>
- # </body>
- # </html>
+ };
+ package main;
+ Template::Declare->init( roots => ['MyApp::Templates']);
+ print Template::Declare->show('main')
+
+ # Output:
+ #
+ # <?xml version="1.0"?>
+ # <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+ #
+ # <groupbox>
+ # <caption label="Colors" />
+ # <radiogroup>
+ # <radio id="orange" label="Orange" />
+ # <radio id="violet" label="Violet" selected="true" />
+ # <radio id="yellow" label="Yellow" />
+ # </radiogroup>
+ # </groupbox>
=head2 A slightly more advanced example
@@ -153,6 +200,7 @@
# <div id="footer">Page last generated at Mon Jul 2 17:09:34 2007.</div>
# </html>
+See L<Template::Declare::Tags> for more examples.
=head2 Multiple template roots (search paths)
@@ -511,7 +559,7 @@
=head1 SEE ALSO
-L<Jifty>
+L<Template::Declare::Tags>, L<Template::Declare::TagSet>, L<Template::Declare::TagSet::HTML>, L<Template::Declare::TagSet::XUL>, L<Jifty>.
=head1 AUTHOR
More information about the Jifty-commit
mailing list