Permalink
Browse files

fixed use of uninitialised value bug and missing pltenjin bug

  • Loading branch information...
1 parent cc49bd8 commit 8a6e5cbb0e713b3e7efb8ae740ae9dbac4062bc3 @ido50 committed Feb 18, 2010
Showing with 80 additions and 8 deletions.
  1. +4 −0 Changes
  2. +2 −1 MANIFEST
  3. +1 −1 META.yml
  4. +0 −2 Makefile.PL
  5. +1 −1 README
  6. +2 −2 lib/Tenjin.pm
  7. +4 −1 lib/Tenjin/Template.pm
  8. +43 −0 t/test_tmpl.html
  9. +23 −0 t/test_tmpl.pl
View
4 Changes
@@ -1,5 +1,9 @@
Revision history for Perl extension Tenjin
+0.051 2010-02-18 18:51:00
+ - Fixed 'use of uninitialized value' warnings caused by $lspace and $rspace
+ - Removed references to pltenjin which caused the Makefile to fail
+
0.05 2010-02-18 12:35:00
- Revised code structure, Tenjin::Engine is now just Tenjin
- Much faster template compilation
View
3 MANIFEST
@@ -10,7 +10,6 @@ inc/Module/Install/Makefile.pm
inc/Module/Install/Metadata.pm
inc/Module/Install/Win32.pm
inc/Module/Install/WriteAll.pm
-script/pltenjin
lib/Tenjin.pm
lib/Tenjin/Context.pm
lib/Tenjin/Preprocessor.pm
@@ -23,3 +22,5 @@ README
t/01use.t
t/02pod.t
t/03podcoverage.t
+t/test_tmpl.pl
+t/test_tmpl.html
View
2 META.yml
@@ -21,4 +21,4 @@ requires:
Encode: 0
resources:
license: http://www.opensource.org/licenses/mit-license.php
-version: 0.05
+version: 0.051
View
2 Makefile.PL
@@ -12,8 +12,6 @@ all_from 'lib/Tenjin.pm';
requires 'Encode' => 0;
requires 'HTML::Entities' => 0;
-install_script 'pltenjin';
-
test_requires 'Test::More';
auto_install;
View
2 README
@@ -20,7 +20,7 @@ SYNOPSIS
print $output;
VERSION
- 0.05
+ 0.051
DESCRIPTION
Tenjin is a very fast and full-featured templating engine, implemented
View
4 lib/Tenjin.pm
@@ -8,7 +8,7 @@ use Tenjin::Util;
use strict;
use warnings;
-our $VERSION = 0.05;
+our $VERSION = 0.051;
our $USE_STRICT = 0;
our $ENCODING = 'utf8';
our $BYPASS_TAINT = 1; # unset if you like taint mode
@@ -208,7 +208,7 @@ Tenjin - Fast templating engine with support for embedded Perl.
=head1 VERSION
-0.05
+0.051
=head1 DESCRIPTION
View
5 lib/Tenjin/Template.pm
@@ -115,7 +115,10 @@ sub parse_stmt {
$self->parse_expr($bufref, $text) if $text;
$mspace = '' if $mspace eq ' ';
$stmt = $self->hook_stmt($stmt);
- $self->add_stmt($bufref, $lspace . $mspace . $stmt . $rspace);
+ $stmt .= $rspace if $rspace;
+ $stmt = $mspace . $stmt if $mspace;
+ $stmt = $lspace . $stmt if $lspace;
+ $self->add_stmt($bufref, $stmt);
}
my $rest = $pos == 0 ? $input : substr($input, $pos);
$self->parse_expr($bufref, $rest) if $rest;
View
43 t/test_tmpl.html
@@ -0,0 +1,43 @@
+foo foo foo foo foo foo foo foo foo foo foo foo
+foo foo foo foo foo foo foo foo foo foo foo foo
+foo foo foo foo foo foo foo foo foo foo foo foo
+foo foo foo foo foo foo foo foo foo foo foo foo
+foo foo foo foo foo foo foo foo foo foo foo foo
+
+[== ${scalar_variable} =]
+[== ${hash_variable}->{hash_value_key} =]
+[== ${array_variable}->[ 2 ] =]
+[== ${this}->{is}->{a}->{very}->{deep}->{hash}->{structure} =]
+<?pl foreach ( @{${array_loop}} ) { ?>[== $_ =]<?pl } ?>
+
+<?pl foreach ( sort( keys( %{${hash_loop}} ) ) ) { ?>[== $_ =]: [== ${hash_loop}->{$_} =]<?pl } ?>
+
+<?pl foreach ( @{${records_loop}} ) { ?>[== $_->{name} =]: [== $_->{age} =]<?pl } ?>
+
+<?pl foreach ( @{${array_loop}} ) { ?>[== $_ =]<?pl } ?>
+
+<?pl foreach ( sort( keys( %{${hash_loop}} ) ) ) { ?>[== $_ =]: [== ${hash_loop}->{$_} =]<?pl } ?>
+
+<?pl foreach ( @{${records_loop}} ) { ?>[== $_->{name} =]: [== $_->{age} =]<?pl } ?>
+
+<?pl if( 1 ) { ?>true<?pl } ?>
+
+<?pl if( ${variable_if} ) { ?>true<?pl } ?>
+
+<?pl if( 1 ) { ?>true<?pl } else { ?>false<?pl } ?>
+
+<?pl if( ${variable_if_else} ) { ?>true<?pl } else { ?>false<?pl } ?>
+
+<?pl if( 1 ) { ?>[== ${template_if_true} =]<?pl } ?>
+
+<?pl if( ${variable_if} ) { ?>[== ${template_if_true} =]<?pl } ?>
+
+<?pl if( 1 ) { ?>[== ${template_if_true} =]<?pl } else { ?>[== ${template_if_false} =]<?pl } ?>
+
+<?pl if( ${variable_if_else} ) { ?>[== ${template_if_true} =]<?pl } else { ?>[== ${template_if_false} =]<?pl } ?>
+
+[== 10 + 12 =]
+[== ${variable_expression_a} * ${variable_expression_b} =]
+[== ( ( ${variable_expression_a} * ${variable_expression_b} ) + ${variable_expression_a} - ${variable_expression_b} ) / ${variable_expression_b} =]
+[== substr( 'this has a substring.', 11, 9 ) =]
+[== substr( ${variable_function_arg}, 4, 2 ) =]
View
23 t/test_tmpl.pl
@@ -0,0 +1,23 @@
+#!/usr/bin/perl -w
+
+use strict;
+use warnings;
+use Tenjin;
+
+my $t = Tenjin->new({ path => ['./'], postfix => '.html' });
+print $t->render('test_tmpl.html', {
+ scalar_variable => 'hello',
+ hash_variable => { hash_value_key => 'sensible' },
+ array_variable => [ undef, undef, 'world' ],
+ this => { is => { a => { very => { deep => { hash => { structure => 'of' } } } } } },
+ array_loop => [ 'soccer', 'sega', 'genesis' ],
+ hash_loop => { 1992 => 'bad', 1993 => 'ok', 1994 => 'good', 1995 => 'perfect' },
+ records_loop => [ { name => 'Ido Perlmuter', age => 25 }, { name => 'Noi Perlmuter', age => 13 } ],
+ variable_if => 1,
+ variable_if_else => undef,
+ template_if_true => 'true.html',
+ template_if_false => 'false.html',
+ variable_expression_a => 2,
+ variable_expression_b => 5,
+ variable_function_arg => 'asf asdf asdfff',
+});

0 comments on commit 8a6e5cb

Please sign in to comment.