[Jifty-commit] r2365 - in Template-Declare: t

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Sun Dec 10 21:15:46 EST 2006


Author: jesse
Date: Sun Dec 10 21:15:46 2006
New Revision: 2365

Added:
   Template-Declare/t/private.t
Modified:
   Template-Declare/   (props changed)

Log:
 r46081 at pinglin:  jesse | 2006-12-11 02:14:42 +0000
 * _tests_ for private templates.
 


Added: Template-Declare/t/private.t
==============================================================================
--- (empty file)
+++ Template-Declare/t/private.t	Sun Dec 10 21:15:46 2006
@@ -0,0 +1,64 @@
+use warnings;
+use strict;
+
+package Wifty::UI;
+use base qw/Template::Declare/;
+use Template::Declare::Tags;
+
+template simple => sub {
+
+    html {
+        head {};
+        body { show 'private-content'; };
+        }
+
+};
+
+private template 'private-content' => sub {
+    with( id => 'body' ), div {
+        outs('This is my content');
+    };
+
+};
+
+package Template::Declare::Tags;
+
+use Test::More qw/no_plan/;
+use HTML::Lint;
+
+our $self;
+local $self = {};
+bless $self, 'Wifty::UI';
+{
+    local $Template::Declare::Tags::BUFFER;
+    my $simple = ( show('simple') );
+   like( $simple,  qr'This is my content' );
+    ok_lint($simple);
+}
+{
+    local $Template::Declare::Tags::BUFFER;
+    my $simple = ( show('does_not_exist') );
+    unlike( $simple , qr'This is my content' );
+    ok_lint($simple);
+}
+{
+    local $Template::Declare::Tags::BUFFER;
+    my $simple = ( show('private-content') );
+    unlike( $simple , qr'This is my content', "Can't call private templates" );
+    ok_lint($simple);
+}
+
+sub ok_lint {
+    my $html = shift;
+
+    my $lint = HTML::Lint->new;
+
+    $lint->parse($html);
+    is( $lint->errors, 0, "Lint checked clean" );
+    foreach my $error ( $lint->errors ) {
+        diag( $error->as_string );
+    }
+
+}
+
+1;


More information about the Jifty-commit mailing list