The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
Changes 150
MANIFEST 42
META.yml 2012
extras/bench_all.pl 34487
extras/lib/Template/Teeny/Stash.pm 810
extras/lib/Template/Teeny.pm 4320
lib/Template/Simple.pm 5014
t/options.t 180
8 files changed (This is a version diff) 964115
@@ -1,20 +1,5 @@
 Revision history for Template-Simple
 
-0.06	Tue May  8 01:53:46 EDT 2012
-	Added support for markup tokens to use a user supplied regex
-	Thanks to Ricky Morse
-		
-0.05	Sun Apr 24 00:27:10 EDT 2011
-      - Updated Changes file
-      - Added handling of undef templates
-      - Added new benchmark in extras/bench_all.pl
-0.05	Fri Jun 24 14:22:58 EDT 2011
-	Wrote new benchmark script in extras/
-	Added to distro modified Template::Teeny for benchmark
-
-0.04    Sun Apr 24 00:27:10 EDT 2011
-      - Fixed bugs in tests (introduced in 0.03)
-
 0.03    Sun Apr  3 04:11:04 EDT 2011
       - Added support for compiled templates
       - Added support to test regular and compiled templates
@@ -4,6 +4,8 @@ META.yml # Will be created by "make dist"
 Makefile.PL
 README
 TODO
+extras/cookbook.pl
+extras/bench_all.pl
 lib/Template/Simple.pm
 t/00-load.t
 t/boilerplate.t
@@ -16,7 +18,3 @@ t/options.t
 t/include.t
 t/error.t
 t/common.pm
-extras/cookbook.pl
-extras/bench_all.pl
-extras/lib/Template/Teeny.pm
-extras/lib/Template/Teeny/Stash.pm
@@ -1,23 +1,15 @@
 --- #YAML:1.0
-name:               Template-Simple
-version:            0.06
-abstract:           A simple and very fast template module
-author:
+name:                Template-Simple
+version:             0.04
+abstract:            A simple and very fast template module
+license:             ~
+author:              
     - Uri Guttman <uri@sysarch.com>
-license:            unknown
-distribution_type:  module
-configure_requires:
-    ExtUtils::MakeMaker:  0
-build_requires:
-    ExtUtils::MakeMaker:  0
-requires:
-    File::Slurp:  0
-    Test::More:   0
-no_index:
-    directory:
-        - t
-        - inc
-generated_by:       ExtUtils::MakeMaker version 6.55_02
+generated_by:        ExtUtils::MakeMaker version 6.42
+distribution_type:   module
+requires:     
+    File::Slurp:                   0
+    Test::More:                    0
 meta-spec:
-    url:      http://module-build.sourceforge.net/META-spec-v1.4.html
-    version:  1.4
+    url:     http://module-build.sourceforge.net/META-spec-v1.3.html
+    version: 1.3
@@ -1,381 +1,124 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
-use lib '../lib' ;
-use lib 'lib' ;
+use strict;
+use warnings;
 
-use warnings ;
-use strict ;
+use Template::Teeny;
+use Template::Simple;
+use Template::Teeny::Stash;
+use Template;
 
-use Data::Dumper ;
+my $iter = shift || -2 ;
 
-use Getopt::Long ;
-use File::Slurp ;
 use Benchmark qw(:hireswallclock cmpthese);
+basic: {
 
-my $opts = parse_options() ;
+    my $ts = Template::Simple->new() ;
+	$ts->add_templates( { bench => 'hehe [% name %]' } ) ;
 
-my $template_info = [
-	{
-		name	=> 'basic',
-		data	=> {
-			name	=> 'bob',
-		},
-		expected => 'hehe bob',
-		simple	=> 'hehe [% name %]',
-		toolkit	=> 'hehe [% name %]',
-		teeny	=> 'hehe [% name %]',
-		tiny	=> 'hehe [% name %]',
-	},
-	{
-		name	=> 'nested',
-		data	=> {
-			title	=> 'Bobs Blog',
-			posts	=> [
-				{
-					title	=> 'hehe',
-					date	=> 'Today'
-				},
-				{
-					title	=> 'Something new',
-					date	=> '3 Days ago',
-				},
-			],
-		},
-		expected => <<EXPECTED,
-<html>
-  <head><title>Bobs Blog</title></head>
-  <body>
-    <ul>
-        <li>
-            <h3>hehe</h3>
-            <span>Today</span>
-        </li>
-        <li>
-            <h3>Something new</h3>
-            <span>3 Days ago</span>
-        </li>
-    </ul>
-  </body>
-</html>
-EXPECTED
+    my $tsc = Template::Simple->new() ;
+	$tsc->add_templates( { bench => 'hehe [% name %]' } ) ;
+	$tsc->compile( 'bench' ) ;
 
-		simple	=> <<SIMPLE,
-<html>
-  <head><title>[% title %]</title></head>
-  <body>
-    <ul>[% START posts %]
-        <li>
-            <h3>[% title %]</h3>
-            <span>[% date %]</span>
-        </li>[% END posts %]
-    </ul>
-  </body>
-</html>
-SIMPLE
+    my $tt = Template::Teeny->new({ include_path => ['t/tpl'] });
+    my $stash = Template::Teeny::Stash->new({ name => 'bob' });
 
-		toolkit	=> <<TOOLKIT,
-<html>
-  <head><title>[% title %]</title></head>
-  <body>
-    <ul>[% FOREACH post = posts %]
-        <li>
-            <h3>[% post.title %]</h3>
-            <span>[% post.date %]</span>
-        </li>[% END %]
-    </ul>
-  </body>
-</html>
-TOOLKIT
+    my $t = Template->new({ INCLUDE_PATH => 't/tpl', COMPILE_EXT => '.tc' });
+    my $out;
+      open my $fh, '>/dev/null';
 
-		tiny	=> <<TINY,
-<html>
-  <head><title>[% title %]</title></head>
-  <body>
-    <ul>[% FOREACH post IN posts %]
-        <li>
-            <h3>[% post.title %]</h3>
-            <span>[% post.date %]</span>
-        </li>[% END %]
-    </ul>
-  </body>
-</html>
-TINY
+    $tt->process('bench.tpl', $stash, $fh);
+    $t->process('bench.tpl', { name => 'bob' }, $fh);
+
+    sub teeny {
+        $tt->process('bench.tpl', $stash, $fh);
+    }
+    sub plain {
+        $t->process('bench.tpl', { name => 'bob' }, $fh);    
+    }
+
+    sub simple {
+        $ts->render('bench', { name => 'bob' } );    
+    }
+
+    sub ts_compiled {
+        $tsc->render('bench', { name => 'bob' } );    
+    }
 
-		teeny	=> <<TEENY,
+    print "Very simple interpolation:\n";
+    cmpthese( $iter, { teeny => \&teeny, template_toolkit => \&plain,
+			simple => \&simple, ts_compiled => \&ts_compiled }) ;
+}
+
+some_looping_etc: {
+
+my $tmpl = <<TMPL ;
 <html>
   <head><title>[% title %]</title></head>
   <body>
-    <ul>[% SECTION post %]
+    <ul>
+      [% SECTION post %]
         <li>
             <h3>[% title %]</h3>
             <span>[% date %]</span>
-        </li>[% END %]
+        </li>
+      [% END %]
     </ul>
   </body>
 </html>
+TMPL
 
-TEENY
-	},
-] ;
+    my $ts = Template::Simple->new() ;
+	$ts->add_templates( { bench2 => $tmpl } ) ;
 
-my $benches = [
-	{
-		name	=> 'T::S',
-		template_key => 'simple',
-		load	=> sub {
-			return eval { require Template::Simple } ;
-		},
-		setup	=> sub {
-			my( $bench, $info ) = @_ ;
+    my $tsc = Template::Simple->new() ;
+	$tsc->add_templates( { bench2 => $tmpl } ) ;
+	$tsc->compile( 'bench2' ) ;
 
-			my $template = $info->{$bench->{template_key}} ;
-			my $data = $info->{data} ;
-			my $name = $info->{name} ;
+    my $tt = Template::Teeny->new({ include_path => ['t/tpl'] });
+    my $stash = Template::Teeny::Stash->new({ title => q{Bobs Blog} });
 
-			my $obj = Template::Simple->new(
-				templates => { $name => $template }
-			) ;
+    my $post1 = Template::Teeny::Stash->new({ date => 'Today', title => 'hehe' });
+    my $post2 = Template::Teeny::Stash->new({ date => '3 Days ago', title => 'Something new' });
+    $stash->add_section('post', $post1);
+    $stash->add_section('post', $post2);
 
-			$bench->{render} =
-				sub { $obj->render( $name, $data ) } ;
-		},
-		verify	=> sub {
-			my( $bench, $info ) = @_ ;
-			my $result = $bench->{render}->() ;
-			$bench->{result} = ${$result} ;
-		},
-	},
-	{
-		name	=> 'T::S compiled',
-		template_key => 'simple',
-		load	=> sub {
-			return eval { require Template::Simple } ;
-		},
-		setup	=> sub {
-			my( $bench, $info ) = @_ ;
+    my $t = Template->new({ INCLUDE_PATH => 't/tpl', COMPILE_EXT => '.tc' });
+    my $out;
+     open my $fh, '>/dev/null';
 
-			my $template = $info->{$bench->{template_key}} ;
-			my $data = $info->{data} ;
-			my $name = $info->{name} ;
+    my $tt_vars = { 
+        title => 'Bobs Blog', 
+        posts => [
+            { title => 'hehe', date => 'Today' },
+            { date => '3 Days ago', title => 'Something new' },
+        ],
+    };
+    teeny2();
+   plain2();
 
-			my $obj = Template::Simple->new(
-				templates => { $name => $template }
-			) ;
-			$obj->compile( $name ) ;
+    sub teeny2 {
+        $tt->process('bench2-teeny.tpl', $stash, $fh);
+    }
+    sub plain2 {
+        $t->process('bench2-tt.tpl', $tt_vars, $fh);    
+    }
 
-			$bench->{render} =
-				sub { $obj->render( $name, $data ) } ;
-		},
-		verify	=> sub {
-			my( $bench, $info ) = @_ ;
-			my $result = $bench->{render}->() ;
-			$bench->{result} = ${$result} ;
-		},
-	},
-	{
-		name	=> 'Teeny',
-		template_key => 'teeny',
-		load	=> sub {
-			return eval {
-				require Template::Teeny ;
-				require Template::Teeny::Stash ;
-			} ;
-		},
-		setup	=> sub {
-			my( $bench, $info ) = @_ ;
+    sub simple2 {
+        $ts->render('bench2', $tt_vars );    
+    }
 
-			my $template = $info->{$bench->{template_key}} ;
-			my $data = $info->{data} ;
-			my $name = $info->{name} ;
+    sub ts_compiled2 {
+        $tsc->render('bench2', $tt_vars );    
+    }
 
-			my $results ;
-#			open my $fh, '>', \$results or
-#			open my $fh, '>', '/dev/null' or
-#				die "can't open string for output" ;
+    print "\nLoop and interpolation:\n";
 
-			mkdir 'tpl' ;
-			write_file( "tpl/$name.tpl", $template ) ;
-			my $obj = Template::Teeny->new(
-				{ include_path => ['tpl'] }
-			) ;
+    cmpthese( $iter, { teeny => \&teeny2, template_toolkit => \&plain2,
+			simple => \&simple2, ts_compiled => \&ts_compiled2 }) ;
 
-			my $stash ;
-			if ( my $posts = $data->{posts} ) {
-			
-				$stash = Template::Teeny::Stash->new(
-					{ title => $data->{title} }
-				) ;
-
-				foreach my $post ( @{$posts} ) {
-
-					my $substash =
-						Template::Teeny::Stash->new(
-							$post
-					) ;
-					$stash->add_section('post', $substash );
-				}
-			}
-			else {
-				$stash = Template::Teeny::Stash->new(
-					$data
-				) ;
-
-			}
-
-#print Dumper $stash ;
-			$bench->{render} =
-				sub { $obj->process("$name.tpl", $stash ); }
-
-		},
-		verify	=> sub {
-			my( $bench, $info ) = @_ ;
-			$bench->{result} = $bench->{render}->() ;
-		},
-	},
-	{
-		name	=> 'toolkit',
-		template_key => 'toolkit',
-		load	=> sub { return eval { require Template } ; },
-		setup	=> sub {
-			my( $bench, $info ) = @_ ;
-
-			my $template = $info->{$bench->{template_key}} ;
-			my $data = $info->{data} ;
-
-			my $obj = Template->new() ;
-
-			$bench->{render} = sub {
-				my $output ;
-				$obj->process(\$template, $data, \$output );
-				return $output ;
-			},
-
-		},
-		verify	=> sub {
-			my( $bench, $info ) = @_ ;
-			$bench->{result} = $bench->{render}->() ;
-		},
-	},
-	{
-		name	=> 'tiny',
-		template_key => 'tiny',
-		load	=> sub { return eval { require Template::Tiny } ; },
-		setup	=> sub {
-			my( $bench, $info ) = @_ ;
-
-			my $template = $info->{$bench->{template_key}} ;
-			my $data = $info->{data} ;
-
-			my $obj = Template::Tiny->new() ;
-
-			$bench->{render} = sub {
-				my $output ;
-				$obj->process( \$template, $data, \$output );
-				return $output ;
-			},
-		},
-		verify	=> sub {
-			my( $bench, $info ) = @_ ;
-			$bench->{result} = $bench->{render}->() ;
-		},
-	},
-] ;
-
-run_benchmarks() ;
-
-sub run_benchmarks {
-
-	foreach my $info ( @{$template_info} ) {
-
-		my %compares ;
-
-		foreach my $bench ( @{$benches} ) {
-
-			my $loaded = $bench->{load}->() ;
-			unless( $loaded ) {
-				print <<BAD ;
-Skipping $bench->{name} as it didn't load
-BAD
-				next ;
-			}
-
-			$bench->{setup}->( $bench, $info ) ;
-
-			if ( $opts->{verify} ) {
-				$bench->{verify}->( $bench, $info ) ;
-
-				if ( $bench->{result} ne $info->{expected} ) {
-
-					print <<BAD ;
-Skipping $bench->{name} as it doesn't have verified results.
-RESULT [$bench->{result}]\nEXPECTED [$info->{expected}]
-BAD
-					next ;
-				}
-				else {
-					print <<GOOD ;
-'$bench->{name}' rendering of '$info->{name}' is verified
-GOOD
-				}
-			}
-
-			$compares{ $bench->{name} } = $bench->{render} ;
-		}
-
-		print "\nBenchmark of '$info->{name}' template\n" ;
-		cmpthese( $opts->{iterations}, \%compares ) ;
-		print "\n" ;
-	}
-}
-
-sub parse_options {
-
-	GetOptions( \my %opts,
-		'verify|v',
-		'iterations|i',
-		'templaters|t',
-		'help|?',
-	) ;
-
-	usage( '' ) if $opts{ 'help' } ;
-
-	$opts{iterations} ||= -2 ;
-
-	$opts{templaters} = [split /,/, $opts{templaters}]
-		if $opts{templaters} ;
-
-	return \%opts ;
 }
 
-sub usage {
 
-	my $err_msg = shift || '' ;
 
-	my $usage = <<'=cut' ;
 
-bench_templates.pl - Benchmark Multiple Templaters
-
-=head1 SYNOPSIS
-
-load_menus.pl [--verify | -v] [--iterations | -i <iter>]
-	[--templaters| -t <templaters>] [--help]
-
-=head1 DESCRIPTION
-
-	--verify | -v			Verify rendered output is correct
-	--iterations | -i <iter>	Iteration count passed to cmpthese
-					Default is -2 (seconds of cpu time)
-	--templaters | -t <templaters>	Comma separated list of templaters
-					to run in this benchmark
-
-	[--help | ?]			Print this help text
-
-=cut
-
-	$usage =~ s/^=\w+.*$//mg ;
-
-	$usage =~ s/\n{2,}/\n\n/g ;
-	$usage =~ s/\A\n+// ;
-
-	die "$err_msg\n$usage" ;
-}
@@ -1,81 +0,0 @@
-package Template::Teeny::Stash;
-
-use Moose;
-use Moose::Util::TypeConstraints;
-
-has vars => (is => 'rw', isa => 'HashRef', default => sub { {} });
-has _sections => (is => 'rw', isa => 'HashRef[ArrayRef]', default => sub { {} });
-
-sub BUILDARGS { return { vars => ($_[1]||{}) }; }
-
-sub sections { @{ $_[0]->_sections->{$_[1]} || [] }; }
-sub add_section {
-    my ($self,$sec,@stashes) = @_;
-    $self->_sections->{$sec} ||= [];
-    push @{ $self->_sections->{$sec} }, (@stashes ? @stashes : undef); 
-}
-
-# XXX - add ability to deal with filters here
-sub get { 
-    # All values return are always strings
-    "" . ( $_[0]->vars->{$_[1]} || '' ); 
-}
-
-__PACKAGE__->meta->make_immutable();
-1;
-
-__END__
-
-=head1 NAME
-
-Template::Teeny::Stash - Object containing stashed variables
-
-=head1 SYNOPSIS
-
-    my $stash = Template::Teeny::Stash->new({
-        a => 1,
-        ...
-    });
-
-    $stash->add_section('section_foo', $other_stash);
-
-Objects of this class store the variables and sections for use with templates.
-
-=head1 METHODS
-
-=head2 new
-
-Basic constructor
-
-=head2 get
-
- # TODO Add filter support
-
-  $stash->get('variable1');
-
-This returns the variable of the supplied name in this stash.
-
-=head2 add_section
-
-  $stash->add_section('topsection', $other_stash);
-
-This adds a stash to the named section.
-
-=head2 sections
-
-  $stash->sections('somesection');
-
-This returns the stashes that have been added to the named section.
-
-=head2 vars
-
-  $stash->vars();
-
-This is an accessor for the variables associated with this stash.
-
-=head2 BUILDARGS
-
-This is a moose thang.
-
-=cut
-
@@ -1,432 +0,0 @@
-package Template::Teeny;
-
-our $VERSION = '0.00_002';
-
-our $CODE_START = <<'END';
-sub {
-    my ($stash_a, $out) = @_;
-END
-
-our $CODE_END = <<'END';
-}
-END
-
-use Moose;
-
-has include_path => (
-    is => 'rw',
-    isa => 'ArrayRef[Str]',
-    required => 1,
-    lazy => 1,
-    default => sub { [qw(.)] },
-);
-
-my ($START,$END) = map { qr{\Q$_\E} } qw([% %]);
-my $DECLARATION = qr{$START (?:.+?) $END}x;
-my $TEXT = qr{
-    (?:\A|(?<=$END))    # Start matching from the start of the file or end of a declaration
-        .*?                 # everything in between
-    (?:\Z|(?=$START))   # Finish at the end of the file or start of another declaration
-}msx;
-my $CHUNKS = qr{
-    ($TEXT)?
-    ($DECLARATION)?
-}msx;
-
-my $IDENT = qr{
-    [a-z][a-z0-9_]+ # any alphanumeric characters and underscores, but must start
-                    # with a letter; everything must be lower case
-}x;
-
-my $SECTION = qr{
-    SECTION \s+ ($IDENT)
-}x;
-my $INCLUDE = qr{
-    INCLUDE \s+ ["']? ([^"']+) ["']?
-}x;
-
-my $VARS = qr{
-    (?: \s* \| \s* )?
-    ( $IDENT )
-}x;
-
-my $DIRECTIVE = qr{
-    $START
-        \s*?
-        (END
-            | $SECTION
-            | $INCLUDE
-            | [a-z0-9_\s\|]+
-        )
-        \s*?
-    $END
-}x;
-
-sub parse {
-    my ($self, $tpl) = @_;
-    my (@chunks) = grep { defined $_ && $_ } ($tpl =~ m{$CHUNKS}g);
-  
-    my @AST;
-    while(my $chunk = shift @chunks){
-        if(my ($dir) = $chunk =~ $DIRECTIVE){
-            if(my ($name) = $dir =~ $SECTION){
-                $name =~ s/['"]//g;
-                push @AST, [SECTION => $name];
-            }elsif(my ($nm) = $dir =~ $INCLUDE){
-                $nm =~ s/['"]//g;
-                push @AST, [INCLUDE => $nm];
-            }elsif($dir =~ m{END}){
-                push @AST, ['END'];
-            }elsif(my (@items) = $dir =~ m{$VARS}g){
-                push @AST, [VARS => [@items]];
-            }
-        } else {
-            push @AST, [TEXT => $chunk];
-        }
-    }
-
-    return [@AST];
-}
-
-# XXX - Tests should be added for this
-sub _optimize {
-    my (undef, $AST) = @_;
-
-    my @OPT;
-
-    while (my $item = shift @$AST){
-        my ($type, $val) = @$item;
-
-        if($type eq 'TEXT' || $type eq 'VARS'){
-            my @long = ($item);
-           
-            # lets see what the next statement is to see if we can concat
-            while( $AST->[0] && ($AST->[0][0] eq 'TEXT' || $AST->[0][0] eq 'VARS') ){
-
-                # move this 
-                push @long, shift @$AST;
-            }
-
-            # if there's only one statement, not much point in concat-ing.
-            if(@long > 1){
-                @long = [ CONCAT => [@long] ];
-            }
-
-            push @OPT, @long;
-        } else {
-            push @OPT, $item;
-        }
-    }
-
-    return [@OPT];
-}
-
-sub compile {
-    my ($self, $AST) = @_;
-
-    my $current_level ||= 0;
-
-    my $code = '';
-    if(!$current_level){
-        $code .= $CODE_START;
-        $code .= 'my $output ;' ;
-
-    }
-
-    my @names = ('a'..'z');
-
-    while(my $item = shift @$AST){
-        my ($type, $val) = @$item;
-
-        if($type eq 'TEXT'){
-            $val =~ s{'}{\\'};
-            $code .= q{  $output .= '}.$val.qq{';\n};
-
-        } elsif ($type eq 'VARS') {
-            $code .= q{  $output .=  $stash_} 
-                    . $names[$current_level] 
-                    . q{->get(qw(} 
-                    . join(' ', @$val)
-                    . qq{));\n};
-
-        } elsif ($type eq 'END'){ 
-            $code .= "  }\n";
-            $current_level--;
-
-        } elsif ($type eq 'SECTION') {
-            my $old = $names[$current_level];
-            my $new = $names[++$current_level];
-
-            $code .= "  for my \$stash_$new ( \$stash_$old\->sections('$val') ) {\n";
-        } elsif ($type eq 'CONCAT') {
-            my ($t,$v) = @{ shift @$val };
-
-            if($t eq 'TEXT'){
-                $v =~ s{'}{\\'};
-                $code .= q{  $output .=  '}.$v.qq{'\n};
-            }elsif($t eq 'VARS'){
-                $code .= q{  $output .=  $stash_} 
-                        . $names[$current_level] 
-                        . q{->get(qw(} 
-                        . join(' ', @$v)
-                        . qq{))};
-            }
-
-            for my $concat (@$val){
-                my ($ct,$cv) = @$concat;
-                
-                if($ct eq 'TEXT'){
-                    $cv =~ s{'}{\\'};
-                    $code .= qq{\n    . '}.$cv.q{'};
-                }elsif($ct eq 'VARS'){
-                    $code .= qq{\n    . \$stash_} 
-                            . $names[$current_level] 
-                            . q{->get(qw(} 
-                            . join(' ', @$cv)
-                            . qq{))};
-                }
-            }
-
-            $code .= ";\n";
-
-        } else {
-            die "Could not understand type '$type'";
-        }
-    }
-
-    if(!$current_level){
-
-        $code .= <<'CODE' ;
-	if ( $out ) {
-		print {$out} $output ;
-	}
-	else {
-		return $output ;
-	}
-CODE
-
-        $code .= $CODE_END;
-    }
-
-#print $code ;
-
-    return $code;
-}
-
-
-my $compiled_tpls = {};
-sub process {
-    my ($self, $tpl, $stash, $fh) = @_;
-
-    if(!$fh){
-#        $fh = \*STDOUT;
-    }
-
-    my $tpl_str = '';
-    
-    # XXX - This should really take the full name
-    my $compile = $compiled_tpls->{ $tpl } ||= do {
-        if(!ref $tpl){
-            $tpl_str .= $self->_get_tpl_str($tpl);
-        }
-
-        my $AST = $self->parse($tpl_str);
-        $AST = $self->_optimize($AST);
-        my $code_str = $self->compile($AST);
-
-        my $coderef = eval($code_str) or die "Could not compile template: $@";
-    };
-    return $compile->($stash, $fh);
-
-#    return;
-}
-
-sub _get_tpl_str {
-    my ($self, $tpl) = @_;
-
-    my $tpl_str = '';
-    my @dirs_to_try = @{ $self->include_path };
-
-    my $file;
-    while(my $dir = shift @dirs_to_try){
-        my $tmp = $dir . '/' . $tpl;
-        if(-e $tmp){
-            $file = $tmp;
-            last;
-        }
-    }
-    
-    die "Could not find $tpl" if(!$file);
-
-    open my $fh, $file or die "Could not open '$file': $!";
-    $tpl_str .= do { local $/; <$fh>; };
-    close $fh or die "Could not close '$file': $!";
-
-    return $tpl_str;
-}
-
-1;
-
-__END__
-
-=head1 NAME
-
-Template::Teeny - Teeny-weeny templating system
-
-=head1 VERSION
-
-Version 0.00_002
-
-=head1 SYNOPSIS
-
-    use Template::Teeny;
-
-    my $tt = Template::Teeny->new({
-        include_path => ['foo/templates']    
-    });
-
-    my $stash = Template::Teeny->new({
-        a => 1, b => 2, c => 3
-    });
-
-    $stash->add_section('items', $item1);
-    $stash->add_section('items', $item2);
-
-    $tt->process('foo.html', $stash);
-
-=head1 DESCRIPTION
-
-Template::Teeny is a more perlish implementation of the concepts in googles
-ctemplate library. The template syntax does not have any conditionals or
-looping directly.
-
-A basic template would look like so:
-
-    Hi [% name %],
-
-    You ordered the following:
-    [% SECTION items %]
-        Title: [% title %]
-        Date: [% date %]
-        Identifier: [% id | uc %]
-
-        [% INCLUDE 'full_description.txt' %]
-
-    [% END %]
-
-When processing the template, we supply a stash object which contains all the
-variables for processing.
-
-=over
-
-=item [% name %]
-
-This pulls variables directly from the current stash.
-
-=item [% SECTION items %]
-
-The current stash may have other stashes associated with it by name
-
-  $stash->add_section('foo', $other_stash);
-
-This would then would run the SECTION block with $other_stash as its
-stash.
-
-=item [% id | uc %]
-
-TODO - This still need implemented
-
-This is a variable which will be run through the filter 'uc' before being
-output. These filters can be chained.
-
-=item [% INCLUDE 'full_description.txt %]
-
-TODO - This still need implemented
-
-This will pull in the template from the file 'full_description.txt'
-
-=item [% END %]
-
-This simply marks the end of a section.
-
-=back
-
-=head2 Why yet another templating system?
-
-There are a multitude of different templating systems out there, so what
-makes this one so different? The aim of this system is to move all business
-logic out of the templates and back into the code where it belongs. This
-means that the templating becomes very lightweight and fast.
-
-The Google CTemplate library is a great example of this approach, however I
-had attempted to bind this to perl and unfortunately was unable to make it
-work correctly enough for production use.
-
-I aim to have a fully working perl version and further down the line
-implement a full C version with XS bindings. Other than that, I wanted to
-have a try at writing parsers/compilers for fun.
-
-=head1 METHODS
-
-=head2 process
-
-    $tt->process('foo/bar/baz.tpl', $stash);
-
-This method takes a template file name and a stash object to be processed.
-
-=head2 parse
-
-    $tt->parse('[% foo %]');
-
-Takes a string representing the template. Returns an AST.
-
-=head2 compile
-
-    my $eval_string = $tt->compile( ...<AST>... );
-
-This method take a generated AST and translates it into an eval-able
-string of perl code.
-
-=head2 include_path
-
-This is an accessor for the template include path.
-
-=head1 AUTHOR
-
-Scott McWhirter, C<< <konobi at cpan.org> >>
-
-=head1 SUPPORT
-
-You can find documentation for this module with the perldoc command.
-
-    perldoc Template::Teeny
-
-You can also look for information at:
-
-=over 4
-
-=item * RT: CPAN's request tracker
-
-L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Template-Teeny>
-
-=item * AnnoCPAN: Annotated CPAN documentation
-
-L<http://annocpan.org/dist/Template-Teeny>
-
-=item * CPAN Ratings
-
-L<http://cpanratings.perl.org/d/Template-Teeny>
-
-=item * Search CPAN
-
-L<http://search.cpan.org/dist/Template-Teeny>
-
-=back
-
-=head1 COPYRIGHT & LICENSE
-
-Copyright 2008 Scott McWhirter, all rights reserved.
-
-This program is released under the following license: BSD
-
-=cut
@@ -8,13 +8,12 @@ use Data::Dumper ;
 use Scalar::Util qw( reftype blessed ) ;
 use File::Slurp ;
 
-our $VERSION = '0.06';
+our $VERSION = '0.04';
 
 my %opt_defaults = (
 
 	pre_delim	=> qr/\[%/,
 	post_delim	=> qr/%\]/,
-	token_re	=> qr/\w+?/,
 	greedy_chunk	=> 0,
 #	upper_case	=> 0,
 #	lower_case	=> 0,
@@ -49,7 +48,7 @@ sub new {
 	$self->{scalar_re} = qr{
 		$self->{pre_delim}
 		\s*			# optional leading whitespace
-		($self->{token_re})	# grab scalar name
+		(\w+?)			# grab scalar name
 		\s*			# optional trailing whitespace
 		$self->{post_delim}
 	}xi ;				# case insensitive
@@ -67,7 +66,7 @@ sub new {
 		\s*			# optional leading whitespace
 		START			# required START token
 		\s+			# required whitespace
-		($self->{token_re})	# grab the chunk name
+		(\w+?)			# grab the chunk name
 		\s*			# optional trailing whitespace
 		$self->{post_delim}
 		($chunk_body)		# grab the chunk body
@@ -89,7 +88,7 @@ sub new {
 		\s*			# optional leading whitespace
 		INCLUDE			# required INCLUDE token
 		\s+			# required whitespace
-		($self->{token_re})	# grab the included template name
+		(\w+?)			# grab the included template name
 		\s*			# optional trailing whitespace
 		$self->{post_delim}
 	}xi ;				# case insensitive
@@ -458,15 +457,8 @@ sub add_templates {
 # copy all the templates from the arg hash and force the values to be
 # scalar refs
 
-	while( my( $name, $tmpl ) = each %{$tmpls} ) {
-
-		defined $tmpl or croak "undefined template value for '$name'" ;
-
-# cache the a scalar ref of the template
-
-		$self->{tmpl_cache}{$name} = ref $tmpl eq 'SCALAR' ?
-			\"${$tmpl}" : \"$tmpl"
-	}
+	@{ $self->{tmpl_cache}}{ keys %{$tmpls} } =
+		map ref $_ eq 'SCALAR' ? \"${$_}" : \"$_", values %{$tmpls} ;
 
 #print Dumper $self->{tmpl_cache} ;
 
@@ -611,7 +603,7 @@ TMPL
 
   # here we add the template to the cache and give it a name
 
-    $tmpl->add_templates( { demo => $template_text } ) ;
+    $tmpl->add_template( demo => $template_text ) ;
 
   # this compiles and then renders that template with the same data
   # but is much faster
@@ -664,22 +656,6 @@ chars. The default is qr/%]/.
 
 	my $rendered = $tmpl->render( '[%FOO%>', 'bar' ) ;
 
-=head2  token_re
-
-This option overrides the regular expression that is used match a
-token or name in the markup. It should be a qr// and you may need to
-escape (with \Q or \) any regex metachars if you want them to be plain
-chars. The default is qr/\w+?/.
-
-	my $tmpl = Template::Simple->new(
-		token_re => qr/[\w-]+?/,
-	);
-
-	my $rendered = $tmpl->render(
-		'[% id-with-hyphens %]',
-		{ 'id-with-hyphens' => 'bar' }
-	) ;
-
 =head2	greedy_chunk
 
 This boolean option will cause the regex that grabs a chunk of text
@@ -732,7 +708,7 @@ template text to be rendered. A scalar template argument is first
 assumed to be a template name which is searched for in the template
 cache and the compiled template caches. If found in there it is used
 as the template. If not found there, it is searched for in the
-directories of the C<search_dirs>. Finally if not found, it will be
+directories of the C<include_paths>. Finally if not found, it will be
 used as the template text.
 
 The data tree argument can be any value allowed by Template::Simple
@@ -848,9 +824,7 @@ and C<post_delim> options in the C<new()> constructor.
 A token is a single markup with a C<\w+> Perl word inside. The token
 can have optional whitespace before and after it. A token is replaced
 by a value looked up in a hash with the token as the key. The hash
-lookup keeps the same case as parsed from the token markup. You can
-override the regular expression used to match a token with the
-C<token_re> option.
+lookup keeps the same case as parsed from the token markup.
 
     [% foo %] [%BAR%]
 
@@ -863,7 +837,7 @@ parsed out during hash data rendering so see Hash Data for more.
 Chunks are regions of text in a template that are marked off with a
 start and end markers with the same name. A chunk start marker is
 C<[%START name%]> and the end marker for that chunk is C<[%END
-name%]>. C<name> is matched with C<\w+?> and that is the name of this
+name%]>. C<name> is a C<\w+> Perl word which is the name of this
 chunk. The whitespace between C<START/END> and C<name> is required and
 there is optional whitespace before C<START/END> and after the
 C<name>. C<START/END> are case insensitive but the C<name>'s case is
@@ -871,8 +845,7 @@ kept.  Chunks are the primary way to markup templates for structures
 (sets of tokens), nesting (hashes of hashes), repeats (array
 references) and callbacks to user code.  By default a chunk will be a
 non-greedy grab but you can change that in the constructor by enabling
-the C<greedy_chunk> option.  You can override the regular expression
-used to match the chunk name with the C<token_re> option.
+the C<greedy_chunk> option.
 
     [%Start FOO%]
 	[% START bar %]
@@ -882,12 +855,9 @@ used to match the chunk name with the C<token_re> option.
 
 =head2 Includes
 
-When a markup C<[%include name%]> is seen, that text is replaced by
-the template of that name. C<name> is matched with C<\w+?> which is
-the name of the template. You can override the regular expression used
-to match the include C<name> with the C<token_re> option.
-
-See C<INCLUDE EXPANSION> for more on this.
+When a markup C<[%include bar%]> is seen, that text is replaced by the
+template of that name. See C<INCLUDE EXPANSION> for more on this.
+=head2 Include Rendering
 
 =head1 RENDERING RULES
 
@@ -898,12 +868,6 @@ unnamed top level chunk of text and it first gets its C<INCLUDE>
 markups rendered. The text then undergoes a chunk rendering and a
 scalar reference to that rendered template is returned to the caller.
 
-=head2 Include Rendering
-
-All include file rendering happens before any other rendering is
-done. After this phase, the rendered template will not have
-C<[%include name%]> markups in it.
-
 =head2 Chunk Rendering
 
 A chunk is the text found between matching C<START> and C<END> markups
@@ -175,24 +175,6 @@ foo
 [%END FOO%]
 EXPECTED
 	},
-	{
-		name	=> 'token_re',
-		opts	=> {
-			token_re => qw/[-\w]+?/,
-		},
-		data	=> {
-			'foo-bar'	=> 'FOO is 3',
-			'BAR-BAZ'	=> 'bar is baz',
-		},
-		template => <<TEMPLATE,
-[%foo-bar%]
-[%BAR-BAZ%]
-TEMPLATE
-		expected => <<EXPECTED,
-FOO is 3
-bar is baz
-EXPECTED
-	},
 ] ;
 
 template_tester( $tests ) ;