[Jifty-commit] r5104 - in Template-Declare: lib/Template lib/Template/Declare

Jifty commits jifty-commit at lists.jifty.org
Thu Feb 14 13:37:40 EST 2008


Author: sartak
Date: Thu Feb 14 13:37:39 2008
New Revision: 5104

Modified:
   Template-Declare/   (props changed)
   Template-Declare/lib/Template/Declare.pm
   Template-Declare/lib/Template/Declare/Tags.pm

Log:
 r51834 at onn:  sartak | 2008-02-14 13:37:31 -0500
 Document the "attr is value" syntax (patch from doy)


Modified: Template-Declare/lib/Template/Declare.pm
==============================================================================
--- Template-Declare/lib/Template/Declare.pm	(original)
+++ Template-Declare/lib/Template/Declare.pm	Thu Feb 14 13:37:39 2008
@@ -189,6 +189,7 @@
     html {
         show('header');
         body {
+            img { src is 'hello.jpg' }
             p { attr { class => 'greeting'};
                 "Hello, $user!"};
             };
@@ -210,14 +211,15 @@
  #   <meta generator="This is not your father&#39;s frontpage" />
  #  </head>
  #  <body>
+ #   <img src="hello.jpg" />
  #   <p class="greeting">Hello, TD user!
  #   </p>
  #  </body>
  #  <div id="footer">Page last generated at Mon Jul  2 17:09:34 2007.</div>
  # </html>
 
-For more options, especially the "native" XML namespace
-support and more samples, see L<Template::Declare::Tags>.
+For more options, especially the "native" XML namespace support, 'is' syntax
+for attributes, and more samples, see L<Template::Declare::Tags>.
 
 =head2 Postprocessing
 
@@ -706,6 +708,13 @@
 
 =item *
 
+The C<is> syntax for declaring tag attributes also requires a trailing semicolon, unless it is the only statement in a block. For example,
+
+    p { class is 'item'; id is 'item1'; outs "This is an item" }
+    img { src is 'cat.gif' }
+
+=item *
+
 Literal strings that have tag siblings won't be captured. So the following template
 
     p { 'hello'; em { 'world' } }

Modified: Template-Declare/lib/Template/Declare/Tags.pm
==============================================================================
--- Template-Declare/lib/Template/Declare/Tags.pm	(original)
+++ Template-Declare/lib/Template/Declare/Tags.pm	Thu Feb 14 13:37:39 2008
@@ -101,6 +101,7 @@
             }
         }
         img { attr { src => 'cat.gif' } }
+        img { src is 'dog.gif' }
     };
 
     # Produces:
@@ -111,6 +112,7 @@
     #  </tr>
     # </table>
     # <img src="cat.gif" />
+    # <img src="dog.gif" />
 
     package MyApp::Templates;
 
@@ -160,7 +162,7 @@
 as they subclass L<Template::Declare::TagSet> and implement
 the corresponding methods (e.g. C<get_tag_list>).
 
-If you implement a custome tag set module named
+If you implement a custom tag set module named
 C<Template::Declare::TagSet::Foo>.
 
  use Template::Declare::Tags 'Foo';
@@ -291,11 +293,18 @@
 
 Example:
 
- p { attr { class => 'greeting text',
-            id => 'welcome' };
-
+ p {
+    attr { class => 'greeting text',
+           id    => 'welcome' };
     'This is a welcoming paragraph';
+ }
 
+Tag attributes can also be specified by using C<is>, as in
+
+ p {
+    class is 'greeting text';
+    id    is 'welcome';
+    'This is a welcoming paragraph';
  }
 
 


More information about the Jifty-commit mailing list