[Jifty-commit] r3904 - in Template-Declare: lib/Template/Declare t

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Tue Aug 14 22:23:56 EDT 2007


Author: agentz
Date: Tue Aug 14 22:23:55 2007
New Revision: 3904

Added:
   Template-Declare/t/indent.t
Modified:
   Template-Declare/MANIFEST
   Template-Declare/lib/Template/Declare/Tags.pm

Log:
[TD]
* documented the variable $Template::Declare::Tags::TAG_NEST_DEPTH which controls the indentation of XML tags.
* added t/indent.t for this.
* updated MANIFEST accordingly.

Modified: Template-Declare/MANIFEST
==============================================================================
--- Template-Declare/MANIFEST	(original)
+++ Template-Declare/MANIFEST	Tue Aug 14 22:23:55 2007
@@ -32,6 +32,7 @@
 t/duplicate_element_ids.t
 t/forms.t
 t/importing.t
+t/indent.t
 t/indexhtml.t
 t/MyTagSet.pm
 t/namespace.t

Modified: Template-Declare/lib/Template/Declare/Tags.pm
==============================================================================
--- Template-Declare/lib/Template/Declare/Tags.pm	(original)
+++ Template-Declare/lib/Template/Declare/Tags.pm	Tue Aug 14 22:23:55 2007
@@ -815,6 +815,27 @@
 Contains the names of the tag subroutines generated
 from certain tag set.
 
+=item C<< $Template::Declare::Tags::TAG_NEST_DEPTH >>
+
+Controls the indentation of the XML tags in the final outputs. For example, you can temporarily disable a tag's indentation by the following lines of code:
+
+    body {
+        pre {
+          local $Template::Declare::Tags::TAG_NEST_DEPTH = 0;
+          script { attr { src => 'foo.js' } }
+        }
+    }
+
+It will generate
+
+    <body>
+     <pre>
+    <script src="foo.js"></script>
+     </pre>
+    </body>
+
+Note that now the C<script> tag has now indentation and we get what we want ;)
+
 =item C<< $Template::Declare::Tags::SKIP_XML_ESCAPING >>
 
 Makes L<Template::Declare> skip the XML escaping

Added: Template-Declare/t/indent.t
==============================================================================
--- (empty file)
+++ Template-Declare/t/indent.t	Tue Aug 14 22:23:55 2007
@@ -0,0 +1,30 @@
+use strict;
+use warnings;
+
+package MyApp::Templates;
+
+use base 'Template::Declare';
+use Template::Declare::Tags 'HTML';
+
+template main => sub {
+    body {
+        pre {
+          local $Template::Declare::Tags::TAG_NEST_DEPTH = 0;
+          script { attr { src => 'foo.js' } }
+        }
+    }
+};
+
+package main;
+use Test::More tests => 1;
+Template::Declare->init( roots => ['MyApp::Templates']);
+my $out = Template::Declare->show('main') . "\n";
+is $out, <<_EOC_;
+
+<body>
+ <pre>
+<script src="foo.js"></script>
+ </pre>
+</body>
+_EOC_
+


More information about the Jifty-commit mailing list