[Jifty-commit] r3871 - Template-Declare
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Mon Aug 13 02:14:16 EDT 2007
Author: agentz
Date: Mon Aug 13 02:14:16 2007
New Revision: 3871
Modified:
Template-Declare/Changes
Template-Declare/README
Log:
TD - updated Changes and README for the upcoming CPAN release 0.26
Modified: Template-Declare/Changes
==============================================================================
--- Template-Declare/Changes (original)
+++ Template-Declare/Changes Mon Aug 13 02:14:16 2007
@@ -1,5 +1,18 @@
0.26 - 2007-08-13
-*
+* Refactored Template::Decalre::Tags to make the tag sets configurable.
+* Added Template::Declare::TagSet::HTML and Template::Declare::TagSet::XUL,
+ respectively, as well as their common base class, Template::Declare::TagSet.
+ Added Template::Declare::TagSet::HTML and Template::Declare::TagSet::XUL,
+ respectively.
+* Added support for XML namespace:
+ use Template::Declare::Tags 'XUL', 'HTML' => { namespace => 'html' };
+ and
+ ... 'HTML' => { namespace => 'html', package => 'MyHtml' };
+* And we can now say 'use Template::Declare::Tags qw/ HTML XUL /;
+* Added @Template::Declare::Tags::TagSubs which records all the tag subroutines
+ generated on-the-fly, which is necessary for secondary symbol exporting
+ in Jifty::View::Declare::Helpers.
+* Implemented C< use Template::Declare::Tags HTML => { from => 'My::HTML::TagSet' } >.
----------------------------------------------------------------------
r57045 (orig r3286): jesse | 2007-05-22 15:58:58 -0400
Modified: Template-Declare/README
==============================================================================
--- Template-Declare/README (original)
+++ Template-Declare/README Mon Aug 13 02:14:16 2007
@@ -1,38 +1,38 @@
-Template::Declare(3) User Contributed Perl Documentation Template::Declare(3)
-
-
-
-NNAAMMEE
- Template::Declare - Perlish declarative templates
-
-SSYYNNOOPPSSIISS
- "Template::Declare" is a pure-perl declarative HTML templating system.
-
- Yes. Another one. There are many others like it, but this one is ours.
-
- A few key features and buzzwords
-
- All templates are 100% pure perl code
- Simple declarative syntax
- No angle brackets
- Mixins
- Inheritance
- Public and private templates
-
-UUSSAAGGEE
- BBaassiicc uussaaggee
+NAME
+ Template::Declare - Perlish declarative templates
+SYNOPSIS
+ "Template::Declare" is a pure-perl declarative HTML/XUL/XML templating
+ system.
+
+ Yes. Another one. There are many others like it, but this one is ours.
+
+ A few key features and buzzwords:
+
+ All templates are 100% pure perl code
+ Simple declarative syntax
+ No angle brackets
+ "Native" XML namespace and declarator support
+ Mixins
+ Inheritance
+ Public and private templates
+
+USAGE
+ Basic usage
+ ##############################
+ # Basic HTML usage:
+ ###############################
package MyApp::Templates;
- use Template::Declare::Tags;
+ use Template::Declare::Tags; # defaults to 'HTML'
use base 'Template::Declare';
template simple => sub {
- html {
- head {}
- body {
- p {'Hello, world wide web!'};
- }
- }
+ html {
+ head {}
+ body {
+ p {'Hello, world wide web!'};
+ }
+ }
};
package main;
@@ -51,136 +51,193 @@
# </body>
# </html>
- AA sslliigghhttllyy mmoorree aaddvvaanncceedd eexxaammppllee
-
- In this example, we'll show off how to set attributes on HTML tags, how
- to call other templates and how to declare a _p_r_i_v_a_t_e template that
- can't be called directly.
-
+ ###############################
+ # Let's do XUL!
+ ###############################
package MyApp::Templates;
- use Template::Declare::Tags;
use base 'Template::Declare';
+ use Template::Declare::Tags 'XUL';
- private template 'header' => sub {
- head {
- title { 'This is a webpage'};
- meta { attr { generator => "This is not your father's frontpage"}}
- }
- };
-
- template simple => sub {
- html {
- show('header');
- body {
- p { attr { class => 'greeting'};
- 'Hello, world wide web!'};
- }
- }
+ 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');
+ print Template::Declare->show('main')
# Output:
#
- # <html>
- # <head>
- # <title>This is a webpage
- # </title>
- # <meta generator="This is not your father's frontpage" />
- # </head>
- # <body>
- # <p class="greeting">Hello, world wide web!
- # </p>
- # </body>
- # </html>
-
- MMuullttiippllee tteemmppllaattee rroooottss ((sseeaarrcchh ppaatthhss))
-
-
- IInnhheerriittaannccee
-
-
- AAlliiaassiinngg
-
-
-MMEETTHHOODDSS
- iinniitt
-
- This _c_l_a_s_s _m_e_t_h_o_d initializes the "Template::Declare" system.
-
- roots
-
- sshhooww TTEEMMPPLLAATTEE__NNAAMMEE
-
- Call "show" with a "template_name" and "Template::Declare" will render
- that template and return the content as a scalar.
-
- aalliiaass
-
- alias Some::Clever::Mixin under '/mixin';
-
- iimmppoorrtt
-
- import Wifty::UI::something under '/something';
-
- hhaass__tteemmppllaattee PPAACCKKAAGGEE TTEEMMPPLLAATTEE__NNAAMMEE SSHHOOWW__PPRRIIVVAATTEE
-
- Takes a package, template name and a boolean. The boolean determines
- whether to show private templates.
-
- Returns a reference to the template's code if found. Otherwise, returns
- undef.
-
- rreessoollvvee__tteemmppllaattee TTEEMMPPLLAATTEE__PPAATTHH IINNCCLLUUDDEE__PPRRIIVVAATTEE__TTEEMMPPLLAATTEESS
-
- Turns a template path ("TEMPLATE_PATH") into a "CODEREF". If the
- boolean "INCLUDE_PRIVATE_TEMPLATES" is true, resolves private template
- in addition to public ones.
-
- First it looks through all the valid Template::Declare roots. For each
- root, it looks to see if the root has a template called $template_name
- directly (or via an "import" statement). Then it looks to see if there
- are any "alias"ed paths for the root with prefixes that match the tem-
- plate we're looking for.
-
- rreeggiisstteerr__tteemmppllaattee PPAACCKKAAGGEE TTEEMMPPLLAATTEE__NNAAMMEE CCOODDEERREEFF
-
- This method registers a template called "TEMPLATE_NAME" in package
- "PACKAGE". As you might guess, "CODEREF" defines the template's imple-
- mentation.
-
- rreeggiisstteerr__tteemmppllaattee PPAACCKKAAGGEE TTEEMMPPLLAATTEE__NNAAMMEE CCOODDEERREEFF
-
- This method registers a private template called "TEMPLATE_NAME" in
- package "PACKAGE". As you might guess, "CODEREF" defines the template's
- implementation.
-
- Private templates can't be called directly from user code but only from
- other templates.
-
-BBUUGGSS
- Crawling all over, baby. Be very, very careful. This code is so cutting
- edge, it can only be fashioned from carbon nanotubes.
-
- Some specific bugs and design flaws that we'd love to see fixed
-
- Output isn't streamy.
-
- If you run into bugs or misfeatures, please report them to "bug-tem-
- plate-declare at rt.cpan.org".
-
-SSEEEE AALLSSOO
- Jifty
-
-AAUUTTHHOORR
- Jesse Vincent <jesse at bestpractical.com>
-
-CCOOPPYYRRIIGGHHTT
- Copyright 2006-2007 Best Practical Solutions, LLC
+ # <?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>
+
+ A slightly more advanced example
+ In this example, we'll show off how to set attributes on HTML tags, how
+ to call other templates and how to declare a *private* template that
+ can't be called directly. We'll also show passing arguments to
+ templates.
+
+ package MyApp::Templates;
+ use Template::Declare::Tags;
+ use base 'Template::Declare';
+
+ private template 'header' => sub {
+ head {
+ title { 'This is a webpage'};
+ meta { attr { generator => "This is not your father's frontpage"}}
+ }
+ };
+
+ private template 'footer' => sub {
+ my $self = shift;
+ my $time = shift || gmtime;
+
+ div { attr { id => "footer"};
+ "Page last generated at $time."
+ }
+ };
+
+ template simple => sub {
+ my $self = shift;
+ my $user = shift || 'world wide web';
+
+ html {
+ show('header');
+ body {
+ p { attr { class => 'greeting'};
+ "Hello, $user!"};
+ };
+ show('footer');
+ }
+ };
+
+ package main;
+ use Template::Declare;
+ Template::Declare->init( roots => ['MyApp::Templates']);
+ print Template::Declare->show( 'simple', 'TD user');
+
+ # Output:
+ #
+ # <html>
+ # <head>
+ # <title>This is a webpage
+ # </title>
+ # <meta generator="This is not your father's frontpage" />
+ # </head>
+ # <body>
+ # <p class="greeting">Hello, TD user!
+ # </p>
+ # </body>
+ # <div id="footer">Page last generated at Mon Jul 2 17:09:34 2007.</div>
+ # </html>
+
+ See Template::Declare::Tags for more examples.
+
+ Multiple template roots (search paths)
+ Inheritance
+ Aliasing
+METHODS
+ init
+ This *class method* initializes the "Template::Declare" system.
+
+ roots
+ postprocessor
+
+ show TEMPLATE_NAME
+ Call "show" with a "template_name" and "Template::Declare" will render
+ that template. Content generated by show can be accessed with the
+ "output" method if the output method you've chosen returns content
+ instead of outputting it directly.
+
+ (If called in scalar context, this method will also just return the
+ content when available).
+
+ alias
+ alias Some::Clever::Mixin under '/mixin';
+
+ import_templates
+ import_templates Wifty::UI::something under '/something';
+
+ path_for $template
+ Returns the path for the template name to be used for show, adjusted
+ with paths used in import_templates.
+
+ has_template PACKAGE TEMPLATE_NAME SHOW_PRIVATE
+ Takes a package, template name and a boolean. The boolean determines
+ whether to show private templates.
+
+ Returns a reference to the template's code if found. Otherwise, returns
+ undef.
+
+ This method is an alias for "resolve_template"
+
+ resolve_template TEMPLATE_PATH INCLUDE_PRIVATE_TEMPLATES
+ Turns a template path ("TEMPLATE_PATH") into a "CODEREF". If the boolean
+ "INCLUDE_PRIVATE_TEMPLATES" is true, resolves private template in
+ addition to public ones.
+
+ First it looks through all the valid Template::Declare roots. For each
+ root, it looks to see if the root has a template called $template_name
+ directly (or via an "import" statement). Then it looks to see if there
+ are any "alias"ed paths for the root with prefixes that match the
+ template we're looking for.
+
+ register_template PACKAGE TEMPLATE_NAME CODEREF
+ This method registers a template called "TEMPLATE_NAME" in package
+ "PACKAGE". As you might guess, "CODEREF" defines the template's
+ implementation.
+
+ register_template PACKAGE TEMPLATE_NAME CODEREF
+ This method registers a private template called "TEMPLATE_NAME" in
+ package "PACKAGE". As you might guess, "CODEREF" defines the template's
+ implementation.
+
+ Private templates can't be called directly from user code but only from
+ other templates.
+
+BUGS
+ Crawling all over, baby. Be very, very careful. This code is so cutting
+ edge, it can only be fashioned from carbon nanotubes.
+
+ Some specific bugs and design flaws that we'd love to see fixed.
+
+ Output isn't streamy.
+
+ If you run into bugs or misfeatures, please report them to
+ "bug-template-declare at rt.cpan.org".
+
+SEE ALSO
+ Template::Declare::Tags, Template::Declare::TagSet,
+ Template::Declare::TagSet::HTML, Template::Declare::TagSet::XUL, Jifty.
+AUTHOR
+ Jesse Vincent <jesse at bestpractical.com>
+COPYRIGHT
+ Copyright 2006-2007 Best Practical Solutions, LLC
-perl v5.8.8 2007-01-18 Template::Declare(3)
More information about the Jifty-commit
mailing list