[Jifty-commit] r6187 - in Template-Declare/branches/markapl-syntax: . lib/Template/Declare
Jifty commits
jifty-commit at lists.jifty.org
Thu Dec 25 15:15:49 EST 2008
Author: gugod
Date: Thu Dec 25 15:15:49 2008
New Revision: 6187
Modified:
Template-Declare/branches/markapl-syntax/ (props changed)
Template-Declare/branches/markapl-syntax/lib/Template/Declare/Tags.pm
Template-Declare/branches/markapl-syntax/t/attributes.t
Log:
r9520 at yra: gugod | 2008-12-26 02:58:42 +0800
can use with() or attr{} to speicifiy attribute now.
Modified: Template-Declare/branches/markapl-syntax/lib/Template/Declare/Tags.pm
==============================================================================
--- Template-Declare/branches/markapl-syntax/lib/Template/Declare/Tags.pm (original)
+++ Template-Declare/branches/markapl-syntax/lib/Template/Declare/Tags.pm Thu Dec 25 15:15:49 2008
@@ -15,9 +15,6 @@
use Symbol 'qualify_to_ref';
use Devel::Declare ();
use B::Hooks::EndOfScope;
-use YAML;
-
-# use Template::Declare::TagCompiler;
our @EXPORT
= qw( with template private show show_page attr outs
@@ -195,9 +192,9 @@
}
my @attr = @_;
- %ATTRIBUTES = ();
if (@attr == 1) {
+ %ATTRIBUTES = ();
my $css = $attr[0];
while ($css =~ /([\#\.])(\w+)/g) {
if ($1 eq '#') {
@@ -206,7 +203,7 @@
$ATTRIBUTES{class} = $2;
}
}
- } else {
+ } elsif(@attr > 1) {
%ATTRIBUTES = (@attr);
}
@@ -231,7 +228,7 @@
my $name = strip_name;
my $proto = strip_proto;
- inject_if_block("no strict; BEGIN { Template::Declare::TagCompiler::inject_scope }; use strict;");
+ inject_if_block("no strict 'subs'; BEGIN { Template::Declare::Tags::inject_scope }; use strict 'subs';");
unless (inject_before_block(defined $proto ? "$proto, sub" : "sub")) {
inject_right_here("($proto)") if defined $proto;
@@ -530,11 +527,11 @@
=cut
-sub attr($;@) {
+sub attr(&;@) {
my $code = shift;
my @rv = $code->();
- while ( my ( $field, $val ) = splice( @rv, 0, 2 ) ) {
+ while ( my ( $field, $val ) = splice( @rv, 0, 2 ) ) {
# only defined whle in a tag context
append_attr( $field, $val );
}
@@ -718,7 +715,6 @@
"HTML appears to contain illegal duplicate element id: $val";
}
}
-
}
wantarray ? () : '';
}
Modified: Template-Declare/branches/markapl-syntax/t/attributes.t
==============================================================================
--- Template-Declare/branches/markapl-syntax/t/attributes.t (original)
+++ Template-Declare/branches/markapl-syntax/t/attributes.t Thu Dec 25 15:15:49 2008
@@ -15,9 +15,9 @@
};
template attr_with_two_args => sub {
- div { attr { id => 'id' }
- p { 'This is my content' }
- }
+ div { attr { id => 'id' }
+ p { 'This is my content' }
+ }
};
template attr_with_many_args => sub {
@@ -31,7 +31,7 @@
template with => sub {
with( id => 'id' ),
- div { p { 'This is my content' } }
+ div { p { 'This is my content' } }
};
template with_with_two_blocks => sub {
@@ -40,11 +40,16 @@
div { p { 'another paragraph' } }
};
+template with_markapl_syntax => sub {
+ div("#id") { p { 'This is my content' } }
+ div { p { 'another paragraph' } }
+};
+
Template::Declare->init(roots => ['Wifty::UI']);
1;
-use Test::More tests => 10;
+use Test::More tests => 12;
require "t/utils.pl";
{
my $simple = (show_page('attr_with_one_arg'));
@@ -52,6 +57,7 @@
#diag ($simple);
ok_lint($simple);
}
+
Template::Declare->buffer->clear;
{
@@ -78,7 +84,7 @@
{
my $simple = (show_page('with'));
ok($simple =~ m{^\s*<div\s+id="id">\s*<p>\s*This is my content\s*</p>\s*</div>\s*$}s);
- #diag ($simple);
+ # diag ($simple);
ok_lint($simple);
}
Template::Declare->buffer->clear;
@@ -89,7 +95,18 @@
<div\s+id="id">\s*<p>\s*This\sis\smy\scontent\s*</p>\s*</div>\s*
<div>\s*<p>\s*another\sparagraph\s*</p>\s*</div>\s*
$}sx);
- #diag ($simple);
+ # diag ($simple);
+ ok_lint($simple);
+}
+Template::Declare->buffer->clear;
+
+{
+ my $simple = (show_page('with_markapl_syntax'));
+ ok($simple =~ m{^\s*
+ <div\s+id="id">\s*<p>\s*This\sis\smy\scontent\s*</p>\s*</div>\s*
+ <div>\s*<p>\s*another\sparagraph\s*</p>\s*</div>\s*
+ $}sx);
+ # diag ($simple);
ok_lint($simple);
}
Template::Declare->buffer->clear;
More information about the Jifty-commit
mailing list