From: Uri Guttman Date: Wed, 9 May 2012 07:20:28 +0000 (-0400) Subject: token_re, include cleanup, git cleanup X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f5c8badf9cff80771975450c60d32c987c7f6af9;p=urisagit%2FTemplate-Simple.git token_re, include cleanup, git cleanup --- diff --git a/Changes b/Changes index 177ebbb..56199de 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,30 @@ 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 Rick 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 + - Improved shared test driver t/common.pm + - include_paths constructor option now called template_paths + include_paths is still supported but deprecated + - Major edits and cleanup of pod + - Created extras/cookbook.pl with runnable T::S examples and pod + - Added extras/bench_all.pl which benchmarks several templaters + 0.02 Tue Oct 17 02:08:28 EDT 2006 - Fixed bug with nested hashes being rendered. Added nested.t to the tests. @@ -7,5 +32,3 @@ Revision history for Template-Simple 0.01 Sun Aug 27 00:07:13 EDT 2006 First release - - diff --git a/MANIFEST b/MANIFEST index 80ecf65..b5b000a 100644 --- a/MANIFEST +++ b/MANIFEST @@ -3,6 +3,7 @@ MANIFEST META.yml # Will be created by "make dist" Makefile.PL README +TODO lib/Template/Simple.pm t/00-load.t t/boilerplate.t @@ -15,3 +16,7 @@ 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 diff --git a/Makefile b/Makefile index db8b045..d99ea81 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,19 @@ # This Makefile is for the Template::Simple extension to perl. # # It was generated automatically by MakeMaker version -# 6.17 (Revision: 1.133) from the contents of +# 6.55_02 (Revision: 65502) from the contents of # Makefile.PL. Don't edit this file, edit Makefile.PL instead. # # ANY CHANGES MADE HERE WILL BE LOST! # # MakeMaker ARGV: () # + # MakeMaker Parameters: # ABSTRACT_FROM => q[lib/Template/Simple.pm] # AUTHOR => q[Uri Guttman ] +# BUILD_REQUIRES => { } # NAME => q[Template::Simple] # PL_FILES => { } # PREREQ_PM => { Test::More=>q[0], File::Slurp=>q[0] } @@ -24,43 +26,43 @@ # --- MakeMaker const_config section: -# These definitions are from config.sh (via /usr/local/lib/perl5/5.8.6/sun4-solaris/Config.pm) - -# They may have been overridden via Makefile.PL or on the command line +# These definitions are from config.sh (via /usr/lib/perl/5.10/Config.pm). +# They may have been overridden via Makefile.PL or on the command line. AR = ar -CC = gcc +CC = cc CCCDLFLAGS = -fPIC -CCDLFLAGS = +CCDLFLAGS = -Wl,-E DLEXT = so DLSRC = dl_dlopen.xs -LD = gcc -LDDLFLAGS = -G -L/usr/local/lib -LDFLAGS = -L/usr/local/lib -LIBC = /lib/libc.so +EXE_EXT = +FULL_AR = /usr/bin/ar +LD = cc +LDDLFLAGS = -shared -O2 -g -L/usr/local/lib -fstack-protector +LDFLAGS = -fstack-protector -L/usr/local/lib +LIBC = LIB_EXT = .a OBJ_EXT = .o -OSNAME = solaris -OSVERS = 2.9 +OSNAME = linux +OSVERS = 2.6.24-28-server RANLIB = : -SITELIBEXP = /usr/local/lib/perl5/site_perl/5.8.6 -SITEARCHEXP = /usr/local/lib/perl5/site_perl/5.8.6/sun4-solaris +SITELIBEXP = /usr/local/share/perl/5.10.1 +SITEARCHEXP = /usr/local/lib/perl/5.10.1 SO = so -EXE_EXT = -FULL_AR = /usr/ccs/bin/ar -VENDORARCHEXP = -VENDORLIBEXP = +VENDORARCHEXP = /usr/lib/perl5 +VENDORLIBEXP = /usr/share/perl5 # --- MakeMaker constants section: AR_STATIC_ARGS = cr DIRFILESEP = / +DFSEP = $(DIRFILESEP) NAME = Template::Simple NAME_SYM = Template_Simple -VERSION = 0.02 +VERSION = 0.06 VERSION_MACRO = VERSION -VERSION_SYM = 0_02 +VERSION_SYM = 0_06 DEFINE_VERSION = -D$(VERSION_MACRO)=\"$(VERSION)\" -XS_VERSION = 0.02 +XS_VERSION = 0.06 XS_VERSION_MACRO = XS_VERSION XS_DEFINE_VERSION = -D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\" INST_ARCHLIB = blib/arch @@ -69,56 +71,60 @@ INST_BIN = blib/bin INST_LIB = blib/lib INST_MAN1DIR = blib/man1 INST_MAN3DIR = blib/man3 -MAN1EXT = 1 -MAN3EXT = 3 +MAN1EXT = 1p +MAN3EXT = 3pm INSTALLDIRS = site DESTDIR = -PREFIX = -PERLPREFIX = /usr/local -SITEPREFIX = /usr/local -VENDORPREFIX = -INSTALLPRIVLIB = $(PERLPREFIX)/lib/perl5/5.8.6 +PREFIX = /usr +PERLPREFIX = $(PREFIX) +SITEPREFIX = $(PREFIX)/local +VENDORPREFIX = $(PREFIX) +INSTALLPRIVLIB = $(PERLPREFIX)/share/perl/5.10 DESTINSTALLPRIVLIB = $(DESTDIR)$(INSTALLPRIVLIB) -INSTALLSITELIB = $(SITEPREFIX)/lib/perl5/site_perl/5.8.6 +INSTALLSITELIB = $(SITEPREFIX)/share/perl/5.10.1 DESTINSTALLSITELIB = $(DESTDIR)$(INSTALLSITELIB) -INSTALLVENDORLIB = +INSTALLVENDORLIB = $(VENDORPREFIX)/share/perl5 DESTINSTALLVENDORLIB = $(DESTDIR)$(INSTALLVENDORLIB) -INSTALLARCHLIB = $(PERLPREFIX)/lib/perl5/5.8.6/sun4-solaris +INSTALLARCHLIB = $(PERLPREFIX)/lib/perl/5.10 DESTINSTALLARCHLIB = $(DESTDIR)$(INSTALLARCHLIB) -INSTALLSITEARCH = $(SITEPREFIX)/lib/perl5/site_perl/5.8.6/sun4-solaris +INSTALLSITEARCH = $(SITEPREFIX)/lib/perl/5.10.1 DESTINSTALLSITEARCH = $(DESTDIR)$(INSTALLSITEARCH) -INSTALLVENDORARCH = +INSTALLVENDORARCH = $(VENDORPREFIX)/lib/perl5 DESTINSTALLVENDORARCH = $(DESTDIR)$(INSTALLVENDORARCH) INSTALLBIN = $(PERLPREFIX)/bin DESTINSTALLBIN = $(DESTDIR)$(INSTALLBIN) INSTALLSITEBIN = $(SITEPREFIX)/bin DESTINSTALLSITEBIN = $(DESTDIR)$(INSTALLSITEBIN) -INSTALLVENDORBIN = +INSTALLVENDORBIN = $(VENDORPREFIX)/bin DESTINSTALLVENDORBIN = $(DESTDIR)$(INSTALLVENDORBIN) INSTALLSCRIPT = $(PERLPREFIX)/bin DESTINSTALLSCRIPT = $(DESTDIR)$(INSTALLSCRIPT) -INSTALLMAN1DIR = $(PERLPREFIX)/man/man1 +INSTALLSITESCRIPT = $(SITEPREFIX)/bin +DESTINSTALLSITESCRIPT = $(DESTDIR)$(INSTALLSITESCRIPT) +INSTALLVENDORSCRIPT = $(VENDORPREFIX)/bin +DESTINSTALLVENDORSCRIPT = $(DESTDIR)$(INSTALLVENDORSCRIPT) +INSTALLMAN1DIR = $(PERLPREFIX)/share/man/man1 DESTINSTALLMAN1DIR = $(DESTDIR)$(INSTALLMAN1DIR) INSTALLSITEMAN1DIR = $(SITEPREFIX)/man/man1 DESTINSTALLSITEMAN1DIR = $(DESTDIR)$(INSTALLSITEMAN1DIR) -INSTALLVENDORMAN1DIR = +INSTALLVENDORMAN1DIR = $(VENDORPREFIX)/share/man/man1 DESTINSTALLVENDORMAN1DIR = $(DESTDIR)$(INSTALLVENDORMAN1DIR) -INSTALLMAN3DIR = $(PERLPREFIX)/man/man3 +INSTALLMAN3DIR = $(PERLPREFIX)/share/man/man3 DESTINSTALLMAN3DIR = $(DESTDIR)$(INSTALLMAN3DIR) INSTALLSITEMAN3DIR = $(SITEPREFIX)/man/man3 DESTINSTALLSITEMAN3DIR = $(DESTDIR)$(INSTALLSITEMAN3DIR) -INSTALLVENDORMAN3DIR = +INSTALLVENDORMAN3DIR = $(VENDORPREFIX)/share/man/man3 DESTINSTALLVENDORMAN3DIR = $(DESTDIR)$(INSTALLVENDORMAN3DIR) -PERL_LIB = /usr/local/lib/perl5/5.8.6 -PERL_ARCHLIB = /usr/local/lib/perl5/5.8.6/sun4-solaris +PERL_LIB = /usr/share/perl/5.10 +PERL_ARCHLIB = /usr/lib/perl/5.10 LIBPERL_A = libperl.a FIRST_MAKEFILE = Makefile -MAKEFILE_OLD = $(FIRST_MAKEFILE).old -MAKE_APERL_FILE = $(FIRST_MAKEFILE).aperl +MAKEFILE_OLD = Makefile.old +MAKE_APERL_FILE = Makefile.aperl PERLMAINCC = $(CC) -PERL_INC = /usr/local/lib/perl5/5.8.6/sun4-solaris/CORE -PERL = /usr/local/bin/perl -FULLPERL = /usr/local/bin/perl +PERL_INC = /usr/lib/perl/5.10/CORE +PERL = /usr/bin/perl +FULLPERL = /usr/bin/perl ABSPERL = $(PERL) PERLRUN = $(PERL) FULLPERLRUN = $(FULLPERL) @@ -127,17 +133,19 @@ PERLRUNINST = $(PERLRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" FULLPERLRUNINST = $(FULLPERLRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" ABSPERLRUNINST = $(ABSPERLRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" PERL_CORE = 0 +PERM_DIR = 755 PERM_RW = 644 PERM_RWX = 755 -MAKEMAKER = /usr/local/lib/perl5/5.8.6/ExtUtils/MakeMaker.pm -MM_VERSION = 6.17 -MM_REVISION = 1.133 +MAKEMAKER = /usr/share/perl/5.10/ExtUtils/MakeMaker.pm +MM_VERSION = 6.55_02 +MM_REVISION = 65502 # FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle). # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle) # PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar) # DLBASE = Basename part of dynamic library. May be just equal BASEEXT. +MAKE = make FULLEXT = Template/Simple BASEEXT = Simple PARENT_NAME = Template @@ -146,6 +154,7 @@ VERSION_FROM = lib/Template/Simple.pm OBJECT = LDFROM = $(OBJECT) LINKTYPE = dynamic +BOOTDEP = # Handy lists of source code files: XS_FILES = @@ -156,7 +165,7 @@ MAN1PODS = MAN3PODS = lib/Template/Simple.pm # Where is the Config information that we are using/depend on -CONFIGDEP = $(PERL_ARCHLIB)$(DIRFILESEP)Config.pm $(PERL_INC)$(DIRFILESEP)config.h +CONFIGDEP = $(PERL_ARCHLIB)$(DFSEP)Config.pm $(PERL_INC)$(DFSEP)config.h # Where to build things INST_LIBDIR = $(INST_LIB)/Template @@ -175,26 +184,26 @@ PERL_ARCHIVE = PERL_ARCHIVE_AFTER = -TO_INST_PM = bug.pl \ - lib/Template/Simple.pm \ - lib/Template/Simple.pm.expnad +TO_INST_PM = lib/14094525_16586370.gwqa \ + lib/Template/14094525_16586370.gwqa \ + lib/Template/Simple.pm -PM_TO_BLIB = lib/Template/Simple.pm.expnad \ - blib/lib/Template/Simple.pm.expnad \ - bug.pl \ - $(INST_LIB)/Template/bug.pl \ +PM_TO_BLIB = lib/Template/14094525_16586370.gwqa \ + blib/lib/Template/14094525_16586370.gwqa \ lib/Template/Simple.pm \ - blib/lib/Template/Simple.pm + blib/lib/Template/Simple.pm \ + lib/14094525_16586370.gwqa \ + blib/lib/14094525_16586370.gwqa # --- MakeMaker platform_constants section: -MM_Unix_VERSION = 1.42 +MM_Unix_VERSION = 6.55_02 PERL_MALLOC_DEF = -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc # --- MakeMaker tool_autosplit section: # Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto -AUTOSPLITFILE = $(PERLRUN) -e 'use AutoSplit; autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1)' +AUTOSPLITFILE = $(ABSPERLRUN) -e 'use AutoSplit; autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1)' -- @@ -206,7 +215,7 @@ SHELL = /bin/sh CHMOD = chmod CP = cp MV = mv -NOOP = $(SHELL) -c true +NOOP = $(TRUE) NOECHO = @ RM_F = rm -f RM_RF = rm -rf @@ -214,20 +223,26 @@ TEST_F = test -f TOUCH = touch UMASK_NULL = umask 0 DEV_NULL = > /dev/null 2>&1 -MKPATH = $(PERLRUN) "-MExtUtils::Command" -e mkpath -EQUALIZE_TIMESTAMP = $(PERLRUN) "-MExtUtils::Command" -e eqtime +MKPATH = $(ABSPERLRUN) -MExtUtils::Command -e 'mkpath' -- +EQUALIZE_TIMESTAMP = $(ABSPERLRUN) -MExtUtils::Command -e 'eqtime' -- +FALSE = false +TRUE = true ECHO = echo ECHO_N = echo -n UNINST = 0 VERBINST = 0 -MOD_INSTALL = $(PERLRUN) -MExtUtils::Install -e 'install({@ARGV}, '\''$(VERBINST)'\'', 0, '\''$(UNINST)'\'');' -DOC_INSTALL = $(PERLRUN) "-MExtUtils::Command::MM" -e perllocal_install -UNINSTALL = $(PERLRUN) "-MExtUtils::Command::MM" -e uninstall -WARN_IF_OLD_PACKLIST = $(PERLRUN) "-MExtUtils::Command::MM" -e warn_if_old_packlist +MOD_INSTALL = $(ABSPERLRUN) -MExtUtils::Install -e 'install([ from_to => {@ARGV}, verbose => '\''$(VERBINST)'\'', uninstall_shadows => '\''$(UNINST)'\'', dir_mode => '\''$(PERM_DIR)'\'' ]);' -- +DOC_INSTALL = $(ABSPERLRUN) -MExtUtils::Command::MM -e 'perllocal_install' -- +UNINSTALL = $(ABSPERLRUN) -MExtUtils::Command::MM -e 'uninstall' -- +WARN_IF_OLD_PACKLIST = $(ABSPERLRUN) -MExtUtils::Command::MM -e 'warn_if_old_packlist' -- +MACROSTART = +MACROEND = +USEMAKEFILE = -f +FIXIN = $(ABSPERLRUN) -MExtUtils::MY -e 'MY->fixin(shift)' -- # --- MakeMaker makemakerdflt section: -makemakerdflt: all +makemakerdflt : all $(NOECHO) $(NOOP) @@ -247,7 +262,7 @@ RCS_LABEL = rcs -Nv$(VERSION_SYM): -q DIST_CP = best DIST_DEFAULT = tardist DISTNAME = Template-Simple -DISTVNAME = Template-Simple-0.02 +DISTVNAME = Template-Simple-0.06 # --- MakeMaker macro section: @@ -270,19 +285,15 @@ DISTVNAME = Template-Simple-0.02 # --- MakeMaker pasthru section: -PASTHRU = LIB="$(LIB)"\ - LIBPERL_A="$(LIBPERL_A)"\ +PASTHRU = LIBPERL_A="$(LIBPERL_A)"\ LINKTYPE="$(LINKTYPE)"\ - PREFIX="$(PREFIX)"\ - OPTIMIZE="$(OPTIMIZE)"\ - PASTHRU_DEFINE="$(PASTHRU_DEFINE)"\ - PASTHRU_INC="$(PASTHRU_INC)" + PREFIX="$(PREFIX)" # --- MakeMaker special_targets section: -.SUFFIXES: .xs .c .C .cpp .i .s .cxx .cc $(OBJ_EXT) +.SUFFIXES : .xs .c .C .cpp .i .s .cxx .cc $(OBJ_EXT) -.PHONY: all config static dynamic test linkext manifest +.PHONY: all config static dynamic test linkext manifest blibdirs clean realclean disttest distdir @@ -306,45 +317,61 @@ pure_all :: config pm_to_blib subdirs linkext subdirs :: $(MYEXTLIB) $(NOECHO) $(NOOP) -config :: $(FIRST_MAKEFILE) $(INST_LIBDIR)$(DIRFILESEP).exists +config :: $(FIRST_MAKEFILE) blibdirs $(NOECHO) $(NOOP) -config :: $(INST_ARCHAUTODIR)$(DIRFILESEP).exists - $(NOECHO) $(NOOP) +help : + perldoc ExtUtils::MakeMaker -config :: $(INST_AUTODIR)$(DIRFILESEP).exists - $(NOECHO) $(NOOP) -$(INST_AUTODIR)/.exists :: /usr/local/lib/perl5/5.8.6/sun4-solaris/CORE/perl.h - $(NOECHO) $(MKPATH) $(INST_AUTODIR) - $(NOECHO) $(EQUALIZE_TIMESTAMP) /usr/local/lib/perl5/5.8.6/sun4-solaris/CORE/perl.h $(INST_AUTODIR)/.exists +# --- MakeMaker blibdirs section: +blibdirs : $(INST_LIBDIR)$(DFSEP).exists $(INST_ARCHLIB)$(DFSEP).exists $(INST_AUTODIR)$(DFSEP).exists $(INST_ARCHAUTODIR)$(DFSEP).exists $(INST_BIN)$(DFSEP).exists $(INST_SCRIPT)$(DFSEP).exists $(INST_MAN1DIR)$(DFSEP).exists $(INST_MAN3DIR)$(DFSEP).exists + $(NOECHO) $(NOOP) - -$(NOECHO) $(CHMOD) $(PERM_RWX) $(INST_AUTODIR) +# Backwards compat with 6.18 through 6.25 +blibdirs.ts : blibdirs + $(NOECHO) $(NOOP) -$(INST_LIBDIR)/.exists :: /usr/local/lib/perl5/5.8.6/sun4-solaris/CORE/perl.h +$(INST_LIBDIR)$(DFSEP).exists :: Makefile.PL $(NOECHO) $(MKPATH) $(INST_LIBDIR) - $(NOECHO) $(EQUALIZE_TIMESTAMP) /usr/local/lib/perl5/5.8.6/sun4-solaris/CORE/perl.h $(INST_LIBDIR)/.exists + $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_LIBDIR) + $(NOECHO) $(TOUCH) $(INST_LIBDIR)$(DFSEP).exists + +$(INST_ARCHLIB)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_ARCHLIB) + $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_ARCHLIB) + $(NOECHO) $(TOUCH) $(INST_ARCHLIB)$(DFSEP).exists - -$(NOECHO) $(CHMOD) $(PERM_RWX) $(INST_LIBDIR) +$(INST_AUTODIR)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_AUTODIR) + $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_AUTODIR) + $(NOECHO) $(TOUCH) $(INST_AUTODIR)$(DFSEP).exists -$(INST_ARCHAUTODIR)/.exists :: /usr/local/lib/perl5/5.8.6/sun4-solaris/CORE/perl.h +$(INST_ARCHAUTODIR)$(DFSEP).exists :: Makefile.PL $(NOECHO) $(MKPATH) $(INST_ARCHAUTODIR) - $(NOECHO) $(EQUALIZE_TIMESTAMP) /usr/local/lib/perl5/5.8.6/sun4-solaris/CORE/perl.h $(INST_ARCHAUTODIR)/.exists + $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_ARCHAUTODIR) + $(NOECHO) $(TOUCH) $(INST_ARCHAUTODIR)$(DFSEP).exists - -$(NOECHO) $(CHMOD) $(PERM_RWX) $(INST_ARCHAUTODIR) +$(INST_BIN)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_BIN) + $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_BIN) + $(NOECHO) $(TOUCH) $(INST_BIN)$(DFSEP).exists -config :: $(INST_MAN3DIR)$(DIRFILESEP).exists - $(NOECHO) $(NOOP) +$(INST_SCRIPT)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_SCRIPT) + $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_SCRIPT) + $(NOECHO) $(TOUCH) $(INST_SCRIPT)$(DFSEP).exists +$(INST_MAN1DIR)$(DFSEP).exists :: Makefile.PL + $(NOECHO) $(MKPATH) $(INST_MAN1DIR) + $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_MAN1DIR) + $(NOECHO) $(TOUCH) $(INST_MAN1DIR)$(DFSEP).exists -$(INST_MAN3DIR)/.exists :: /usr/local/lib/perl5/5.8.6/sun4-solaris/CORE/perl.h +$(INST_MAN3DIR)$(DFSEP).exists :: Makefile.PL $(NOECHO) $(MKPATH) $(INST_MAN3DIR) - $(NOECHO) $(EQUALIZE_TIMESTAMP) /usr/local/lib/perl5/5.8.6/sun4-solaris/CORE/perl.h $(INST_MAN3DIR)/.exists - - -$(NOECHO) $(CHMOD) $(PERM_RWX) $(INST_MAN3DIR) + $(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_MAN3DIR) + $(NOECHO) $(TOUCH) $(INST_MAN3DIR)$(DFSEP).exists -help: - perldoc ExtUtils::MakeMaker # --- MakeMaker linkext section: @@ -388,9 +415,8 @@ POD2MAN = $(POD2MAN_EXE) manifypods : pure_all \ - lib/Template/Simple.pm \ lib/Template/Simple.pm - $(NOECHO) $(POD2MAN) --section=3 --perm_rw=$(PERM_RW)\ + $(NOECHO) $(POD2MAN) --section=$(MAN3EXT) --perm_rw=$(PERM_RW) \ lib/Template/Simple.pm $(INST_MAN3DIR)/Template::Simple.$(MAN3EXT) @@ -417,8 +443,25 @@ clean_subdirs : # the Makefile here so a later make realclean still has a makefile to use. clean :: clean_subdirs - -$(RM_RF) Template-Simple-* ./blib $(MAKE_APERL_FILE) $(INST_ARCHAUTODIR)/extralibs.all $(INST_ARCHAUTODIR)/extralibs.ld perlmain.c tmon.out mon.out so_locations pm_to_blib *$(OBJ_EXT) *$(LIB_EXT) perl.exe perl perl$(EXE_EXT) $(BOOTSTRAP) $(BASEEXT).bso $(BASEEXT).def lib$(BASEEXT).def $(BASEEXT).exp $(BASEEXT).x core core.*perl.*.? *perl.core core.[0-9] core.[0-9][0-9] core.[0-9][0-9][0-9] core.[0-9][0-9][0-9][0-9] core.[0-9][0-9][0-9][0-9][0-9] - -$(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) $(DEV_NULL) + - $(RM_F) \ + *$(LIB_EXT) core \ + core.[0-9] $(INST_ARCHAUTODIR)/extralibs.all \ + core.[0-9][0-9] $(BASEEXT).bso \ + pm_to_blib.ts core.[0-9][0-9][0-9][0-9] \ + $(BASEEXT).x $(BOOTSTRAP) \ + perl$(EXE_EXT) tmon.out \ + *$(OBJ_EXT) pm_to_blib \ + $(INST_ARCHAUTODIR)/extralibs.ld blibdirs.ts \ + core.[0-9][0-9][0-9][0-9][0-9] *perl.core \ + core.*perl.*.? $(MAKE_APERL_FILE) \ + perl $(BASEEXT).def \ + core.[0-9][0-9][0-9] mon.out \ + lib$(BASEEXT).def perlmain.c \ + perl.exe so_locations \ + $(BASEEXT).exp + - $(RM_RF) \ + Template-Simple-* blib + - $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) $(DEV_NULL) # --- MakeMaker realclean_subdirs section: @@ -427,34 +470,46 @@ realclean_subdirs : # --- MakeMaker realclean section: - -# Delete temporary files (via clean) and also delete installed files +# Delete temporary files (via clean) and also delete dist files realclean purge :: clean realclean_subdirs - $(RM_RF) $(INST_AUTODIR) $(INST_ARCHAUTODIR) - $(RM_RF) $(DISTVNAME) - $(RM_F) $(INST_LIB)/Template/bug.pl blib/lib/Template/Simple.pm.expnad blib/lib/Template/Simple.pm $(MAKEFILE_OLD) $(FIRST_MAKEFILE) + - $(RM_F) \ + $(MAKEFILE_OLD) $(FIRST_MAKEFILE) + - $(RM_RF) \ + $(DISTVNAME) # --- MakeMaker metafile section: -metafile : - $(NOECHO) $(ECHO) '# http://module-build.sourceforge.net/META-spec.html' > META.yml - $(NOECHO) $(ECHO) '#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#' >> META.yml - $(NOECHO) $(ECHO) 'name: Template-Simple' >> META.yml - $(NOECHO) $(ECHO) 'version: 0.02' >> META.yml - $(NOECHO) $(ECHO) 'version_from: lib/Template/Simple.pm' >> META.yml - $(NOECHO) $(ECHO) 'installdirs: site' >> META.yml - $(NOECHO) $(ECHO) 'requires:' >> META.yml - $(NOECHO) $(ECHO) ' File::Slurp: 0' >> META.yml - $(NOECHO) $(ECHO) ' Test::More: 0' >> META.yml - $(NOECHO) $(ECHO) '' >> META.yml - $(NOECHO) $(ECHO) 'distribution_type: module' >> META.yml - $(NOECHO) $(ECHO) 'generated_by: ExtUtils::MakeMaker version 6.17' >> META.yml - - -# --- MakeMaker metafile_addtomanifest section: -metafile_addtomanifest: - $(NOECHO) $(PERLRUN) -MExtUtils::Manifest=maniadd -e 'eval { maniadd({q{META.yml} => q{Module meta-data (added by MakeMaker)}}) } ' \ - -e ' or print "Could not add META.yml to MANIFEST: $${'\''@'\''}\n"' +metafile : create_distdir + $(NOECHO) $(ECHO) Generating META.yml + $(NOECHO) $(ECHO) '--- #YAML:1.0' > META_new.yml + $(NOECHO) $(ECHO) 'name: Template-Simple' >> META_new.yml + $(NOECHO) $(ECHO) 'version: 0.06' >> META_new.yml + $(NOECHO) $(ECHO) 'abstract: A simple and very fast template module' >> META_new.yml + $(NOECHO) $(ECHO) 'author:' >> META_new.yml + $(NOECHO) $(ECHO) ' - Uri Guttman ' >> META_new.yml + $(NOECHO) $(ECHO) 'license: unknown' >> META_new.yml + $(NOECHO) $(ECHO) 'distribution_type: module' >> META_new.yml + $(NOECHO) $(ECHO) 'configure_requires:' >> META_new.yml + $(NOECHO) $(ECHO) ' ExtUtils::MakeMaker: 0' >> META_new.yml + $(NOECHO) $(ECHO) 'build_requires:' >> META_new.yml + $(NOECHO) $(ECHO) ' ExtUtils::MakeMaker: 0' >> META_new.yml + $(NOECHO) $(ECHO) 'requires:' >> META_new.yml + $(NOECHO) $(ECHO) ' File::Slurp: 0' >> META_new.yml + $(NOECHO) $(ECHO) ' Test::More: 0' >> META_new.yml + $(NOECHO) $(ECHO) 'no_index:' >> META_new.yml + $(NOECHO) $(ECHO) ' directory:' >> META_new.yml + $(NOECHO) $(ECHO) ' - t' >> META_new.yml + $(NOECHO) $(ECHO) ' - inc' >> META_new.yml + $(NOECHO) $(ECHO) 'generated_by: ExtUtils::MakeMaker version 6.55_02' >> META_new.yml + $(NOECHO) $(ECHO) 'meta-spec:' >> META_new.yml + $(NOECHO) $(ECHO) ' url: http://module-build.sourceforge.net/META-spec-v1.4.html' >> META_new.yml + $(NOECHO) $(ECHO) ' version: 1.4' >> META_new.yml + -$(NOECHO) $(MV) META_new.yml $(DISTVNAME)/META.yml + + +# --- MakeMaker signature section: +signature : + cpansign -s # --- MakeMaker dist_basics section: @@ -471,15 +526,15 @@ manifest : $(PERLRUN) "-MExtUtils::Manifest=mkmanifest" -e mkmanifest veryclean : realclean - $(RM_F) *~ *.orig */*~ */*.orig + $(RM_F) *~ */*~ *.orig */*.orig *.bak */*.bak *.old */*.old # --- MakeMaker dist_core section: dist : $(DIST_DEFAULT) $(FIRST_MAKEFILE) - $(NOECHO) $(PERLRUN) -l -e 'print '\''Warning: Makefile possibly out of date with $(VERSION_FROM)'\''' \ - -e ' if -e '\''$(VERSION_FROM)'\'' and -M '\''$(VERSION_FROM)'\'' < -M '\''$(FIRST_MAKEFILE)'\'';' + $(NOECHO) $(ABSPERLRUN) -l -e 'print '\''Warning: Makefile possibly out of date with $(VERSION_FROM)'\''' \ + -e ' if -e '\''$(VERSION_FROM)'\'' and -M '\''$(VERSION_FROM)'\'' < -M '\''$(FIRST_MAKEFILE)'\'';' -- tardist : $(DISTVNAME).tar$(SUFFIX) $(NOECHO) $(NOOP) @@ -512,21 +567,24 @@ shdist : distdir # --- MakeMaker distdir section: -distdir : metafile metafile_addtomanifest +create_distdir : $(RM_RF) $(DISTVNAME) $(PERLRUN) "-MExtUtils::Manifest=manicopy,maniread" \ -e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');" +distdir : create_distdir distmeta + $(NOECHO) $(NOOP) -# --- MakeMaker dist_test section: +# --- MakeMaker dist_test section: disttest : distdir - cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL + cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL cd $(DISTVNAME) && $(MAKE) $(PASTHRU) cd $(DISTVNAME) && $(MAKE) test $(PASTHRU) + # --- MakeMaker dist_ci section: ci : @@ -536,19 +594,41 @@ ci : -e "print(qq{Executing $(RCS_LABEL) ...\n}); system(qq{$(RCS_LABEL) @all});" +# --- MakeMaker distmeta section: +distmeta : create_distdir metafile + $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) -MExtUtils::Manifest=maniadd -e 'eval { maniadd({q{META.yml} => q{Module meta-data (added by MakeMaker)}}) } ' \ + -e ' or print "Could not add META.yml to MANIFEST: $${'\''@'\''}\n"' -- + + + +# --- MakeMaker distsignature section: +distsignature : create_distdir + $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) -MExtUtils::Manifest=maniadd -e 'eval { maniadd({q{SIGNATURE} => q{Public-key signature (added by MakeMaker)}}) } ' \ + -e ' or print "Could not add SIGNATURE to MANIFEST: $${'\''@'\''}\n"' -- + $(NOECHO) cd $(DISTVNAME) && $(TOUCH) SIGNATURE + cd $(DISTVNAME) && cpansign -s + + + # --- MakeMaker install section: -install :: all pure_install doc_install +install :: pure_install doc_install + $(NOECHO) $(NOOP) -install_perl :: all pure_perl_install doc_perl_install +install_perl :: pure_perl_install doc_perl_install + $(NOECHO) $(NOOP) -install_site :: all pure_site_install doc_site_install +install_site :: pure_site_install doc_site_install + $(NOECHO) $(NOOP) -install_vendor :: all pure_vendor_install doc_vendor_install +install_vendor :: pure_vendor_install doc_vendor_install + $(NOECHO) $(NOOP) pure_install :: pure_$(INSTALLDIRS)_install + $(NOECHO) $(NOOP) doc_install :: doc_$(INSTALLDIRS)_install + $(NOECHO) $(NOOP) pure__install : pure_site_install $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site @@ -556,10 +636,8 @@ pure__install : pure_site_install doc__install : doc_site_install $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site -pure_perl_install :: - $(NOECHO) $(MOD_INSTALL) \ - read $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist \ - write $(DESTINSTALLARCHLIB)/auto/$(FULLEXT)/.packlist \ +pure_perl_install :: all + $(NOECHO) umask 022; $(MOD_INSTALL) \ $(INST_LIB) $(DESTINSTALLPRIVLIB) \ $(INST_ARCHLIB) $(DESTINSTALLARCHLIB) \ $(INST_BIN) $(DESTINSTALLBIN) \ @@ -570,79 +648,59 @@ pure_perl_install :: $(SITEARCHEXP)/auto/$(FULLEXT) -pure_site_install :: - $(NOECHO) $(MOD_INSTALL) \ +pure_site_install :: all + $(NOECHO) umask 02; $(MOD_INSTALL) \ read $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist \ write $(DESTINSTALLSITEARCH)/auto/$(FULLEXT)/.packlist \ $(INST_LIB) $(DESTINSTALLSITELIB) \ $(INST_ARCHLIB) $(DESTINSTALLSITEARCH) \ $(INST_BIN) $(DESTINSTALLSITEBIN) \ - $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \ + $(INST_SCRIPT) $(DESTINSTALLSITESCRIPT) \ $(INST_MAN1DIR) $(DESTINSTALLSITEMAN1DIR) \ $(INST_MAN3DIR) $(DESTINSTALLSITEMAN3DIR) $(NOECHO) $(WARN_IF_OLD_PACKLIST) \ $(PERL_ARCHLIB)/auto/$(FULLEXT) -pure_vendor_install :: - $(NOECHO) $(MOD_INSTALL) \ - read $(VENDORARCHEXP)/auto/$(FULLEXT)/.packlist \ - write $(DESTINSTALLVENDORARCH)/auto/$(FULLEXT)/.packlist \ +pure_vendor_install :: all + $(NOECHO) umask 022; $(MOD_INSTALL) \ $(INST_LIB) $(DESTINSTALLVENDORLIB) \ $(INST_ARCHLIB) $(DESTINSTALLVENDORARCH) \ $(INST_BIN) $(DESTINSTALLVENDORBIN) \ - $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \ + $(INST_SCRIPT) $(DESTINSTALLVENDORSCRIPT) \ $(INST_MAN1DIR) $(DESTINSTALLVENDORMAN1DIR) \ $(INST_MAN3DIR) $(DESTINSTALLVENDORMAN3DIR) -doc_perl_install :: - $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod - -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) - -$(NOECHO) $(DOC_INSTALL) \ - "Module" "$(NAME)" \ - "installed into" "$(INSTALLPRIVLIB)" \ - LINKTYPE "$(LINKTYPE)" \ - VERSION "$(VERSION)" \ - EXE_FILES "$(EXE_FILES)" \ - >> $(DESTINSTALLARCHLIB)/perllocal.pod +doc_perl_install :: all -doc_site_install :: - $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod - -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) - -$(NOECHO) $(DOC_INSTALL) \ +doc_site_install :: all + $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLSITEARCH)/perllocal.pod + -$(NOECHO) umask 02; $(MKPATH) $(DESTINSTALLSITEARCH) + -$(NOECHO) umask 02; $(DOC_INSTALL) \ "Module" "$(NAME)" \ "installed into" "$(INSTALLSITELIB)" \ LINKTYPE "$(LINKTYPE)" \ VERSION "$(VERSION)" \ EXE_FILES "$(EXE_FILES)" \ - >> $(DESTINSTALLARCHLIB)/perllocal.pod + >> $(DESTINSTALLSITEARCH)/perllocal.pod -doc_vendor_install :: - $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod - -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB) - -$(NOECHO) $(DOC_INSTALL) \ - "Module" "$(NAME)" \ - "installed into" "$(INSTALLVENDORLIB)" \ - LINKTYPE "$(LINKTYPE)" \ - VERSION "$(VERSION)" \ - EXE_FILES "$(EXE_FILES)" \ - >> $(DESTINSTALLARCHLIB)/perllocal.pod +doc_vendor_install :: all uninstall :: uninstall_from_$(INSTALLDIRS)dirs + $(NOECHO) $(NOOP) uninstall_from_perldirs :: - $(NOECHO) $(UNINSTALL) $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist uninstall_from_sitedirs :: $(NOECHO) $(UNINSTALL) $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist uninstall_from_vendordirs :: - $(NOECHO) $(UNINSTALL) $(VENDORARCHEXP)/auto/$(FULLEXT)/.packlist + # --- MakeMaker force section: # Phony target to force checking subdirectories. -FORCE: +FORCE : $(NOECHO) $(NOOP) @@ -650,19 +708,18 @@ FORCE: # --- MakeMaker makefile section: - # We take a very conservative approach here, but it's worth it. # We move Makefile to Makefile.old here to avoid gnu make looping. $(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP) $(NOECHO) $(ECHO) "Makefile out-of-date with respect to $?" $(NOECHO) $(ECHO) "Cleaning current config before rebuilding Makefile..." - $(NOECHO) $(RM_F) $(MAKEFILE_OLD) - $(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) - -$(MAKE) -f $(MAKEFILE_OLD) clean $(DEV_NULL) || $(NOOP) + -$(NOECHO) $(RM_F) $(MAKEFILE_OLD) + -$(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) + - $(MAKE) $(USEMAKEFILE) $(MAKEFILE_OLD) clean $(DEV_NULL) $(PERLRUN) Makefile.PL $(NOECHO) $(ECHO) "==> Your Makefile has been rebuilt. <==" - $(NOECHO) $(ECHO) "==> Please rerun the make command. <==" - false + $(NOECHO) $(ECHO) "==> Please rerun the $(MAKE) command. <==" + $(FALSE) @@ -670,12 +727,12 @@ $(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP) # --- MakeMaker makeaperl section --- MAP_TARGET = perl -FULLPERL = /usr/local/bin/perl +FULLPERL = /usr/bin/perl $(MAP_TARGET) :: static $(MAKE_APERL_FILE) - $(MAKE) -f $(MAKE_APERL_FILE) $@ + $(MAKE) $(USEMAKEFILE) $(MAKE_APERL_FILE) $@ -$(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) +$(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) pm_to_blib $(NOECHO) $(ECHO) Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET) $(NOECHO) $(PERLRUNINST) \ Makefile.PL DIR= \ @@ -693,7 +750,11 @@ TESTDB_SW = -d testdb :: testdb_$(LINKTYPE) -test :: $(TEST_TYPE) +test :: $(TEST_TYPE) subdirs-test + +subdirs-test :: + $(NOECHO) $(NOOP) + test_dynamic :: pure_all PERL_DL_NONLAZY=1 $(FULLPERLRUN) "-MExtUtils::Command::MM" "-e" "test_harness($(TEST_VERBOSE), '$(INST_LIB)', '$(INST_ARCHLIB)')" $(TEST_FILES) @@ -709,16 +770,14 @@ testdb_static :: testdb_dynamic # --- MakeMaker ppd section: # Creates a PPD (Perl Package Description) for a binary distribution. -ppd: - $(NOECHO) $(ECHO) '' > $(DISTNAME).ppd - $(NOECHO) $(ECHO) ' $(DISTNAME)' >> $(DISTNAME).ppd - $(NOECHO) $(ECHO) ' A simple and fast template module' >> $(DISTNAME).ppd +ppd : + $(NOECHO) $(ECHO) '' > $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' A simple and very fast template module' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' Uri Guttman <uri@sysarch.com>' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd - $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd - $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd - $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd - $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd + $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) ' ' >> $(DISTNAME).ppd $(NOECHO) $(ECHO) '' >> $(DISTNAME).ppd @@ -726,12 +785,13 @@ ppd: # --- MakeMaker pm_to_blib section: -pm_to_blib: $(TO_INST_PM) - $(NOECHO) $(PERLRUN) -MExtUtils::Install -e 'pm_to_blib({@ARGV}, '\''$(INST_LIB)/auto'\'', '\''$(PM_FILTER)'\'')'\ - lib/Template/Simple.pm.expnad blib/lib/Template/Simple.pm.expnad \ - bug.pl $(INST_LIB)/Template/bug.pl \ - lib/Template/Simple.pm blib/lib/Template/Simple.pm - $(NOECHO) $(TOUCH) $@ +pm_to_blib : $(FIRST_MAKEFILE) $(TO_INST_PM) + $(NOECHO) $(ABSPERLRUN) -MExtUtils::Install -e 'pm_to_blib({@ARGV}, '\''$(INST_LIB)/auto'\'', q[$(PM_FILTER)], '\''$(PERM_DIR)'\'')' -- \ + lib/Template/14094525_16586370.gwqa blib/lib/Template/14094525_16586370.gwqa \ + lib/Template/Simple.pm blib/lib/Template/Simple.pm \ + lib/14094525_16586370.gwqa blib/lib/14094525_16586370.gwqa + $(NOECHO) $(TOUCH) pm_to_blib + # --- MakeMaker selfdocument section: diff --git a/bench.pl b/bench.pl deleted file mode 100644 index de2908f..0000000 --- a/bench.pl +++ /dev/null @@ -1,342 +0,0 @@ -#!/usr/local/bin/perl - -use strict ; -use warnings ; - -use Template::Simple ; -use Benchmark qw( timethese cmpthese ) ; -use Data::Dumper ; - -my @dims = @ARGV ? (shift, shift) : ( 3, 5 ) ; - -my $data = generate_data( @dims ) ; -#print Dumper $data ; - -my $tmpl = Template::Simple->new() ; -my $comp = Template::Simple->new() ; - -my $template = <add_templates( { bench => $template } ) ; -my $rendered = $tmpl->render( 'bench', $data ) ; - -$comp->add_templates( { bench => $template } ) ; -$comp->compile( 'bench' ) ; -my $comp_rendered = $comp->render( 'bench', $data ) ; -#print $comp->get_source( 'bench' ) ; - -my $ok = $$rendered eq $$comp_rendered ; -print "OK comp [$ok]\n" ; - -my $appended = append( $data ) ; -$ok = $$rendered eq $$appended ; -print "OK append [$ok]\n" ; - -#print $$rendered ; -#my $joined = joined( $data ) ; -# print $$rendered ; -# print "----\n" ; -# print $$joined ; -# print $$comp_rendered ; - -cmpthese( shift || -2, - { - render => sub { my $x = $tmpl->render( 'bench', $data ) }, -# joined => sub { my $x = joined( $data ) }, -# concat => sub { my $x = concat( $data ) }, - append => sub { my $x = append( $data ) }, -# compiler => sub { my $x = $comp->compile( 'bench' ) }, - compiled => sub { my $x = $comp->render( 'bench', $data ) }, - } -) ; - -exit ; - -no warnings ; - -sub joined { - -no warnings ; - - my( $data ) = @_ ; - - my $out = do { - my $out ; - - my @data = $data ; - while( defined( my $data = shift @data ) ) { - - if ( ref $data eq 'ARRAY' ) { - push @data, @{$data} ; - next ; - } - - $out .= ref $data ne 'HASH' ? $data : - - join( '', - "Header\nVal 1: " - , - $data->{val_1} - , - "\n" - , - do { - my $data = $data->{nest} ; - my $out ; - - my @data = $data ; - while( defined( my $data = shift @data ) ) { - - if ( ref $data eq 'ARRAY' ) { - push @data, @{$data} ; - next ; - } - - $out .= ref $data ne 'HASH' ? $data : - join( '', - "\n\tLevel: " - , - $data->{level} - , - "\n" ) ; - } - $out ; - } - , - "\n" - , - do { - my $data = $data->{opt} ; - my $out ; - - my @data = $data ; - while( defined( my $data = shift @data ) ) { - - if ( ref $data eq 'ARRAY' ) { - push @data, @{$data} ; - next ; - } - - $out .= ref $data ne 'HASH' ? $data : - join( '', - "\n\tOptional Level: " - , - $data->{level} - , - "\n" ) ; - } - $out ; - } - , - "\nVal 2: " - , - $data->{val_2} - , - "\nFooter\n" ) ; - } - $out ; - } ; - - return \$out ; -} - - -sub concat { - -no warnings ; - - my( $data ) = @_ ; - - my $out = do { - my $out ; - - my @data = $data ; - while( defined( my $data = shift @data ) ) { - - if ( ref $data eq 'ARRAY' ) { - push @data, @{$data} ; - next ; - } - - $out .= ref $data ne 'HASH' ? $data : - "Header\nVal 1: " - . - $data->{val_1} - . - "\n" - . - do { - my $data = $data->{nest} ; - my $out ; - - my @data = $data ; - while( defined( my $data = shift @data ) ) { - - if ( ref $data eq 'ARRAY' ) { - push @data, @{$data} ; - next ; - } - - $out .= ref $data ne 'HASH' ? $data : - "\n\tLevel: " - . - $data->{level} - . - "\n" ; - } - $out ; - } - . - "\n" - . - do { - my $data = $data->{opt} ; - my $out ; - - my @data = $data ; - while( defined( my $data = shift @data ) ) { - - if ( ref $data eq 'ARRAY' ) { - push @data, @{$data} ; - next ; - } - - $out .= ref $data ne 'HASH' ? $data : - "\n\tOptional Level: " - . - $data->{level} - . - "\n" ; - } - $out ; - } - . - "\nVal 2: " - . - $data->{val_2} - . - "\nFooter\n" ; - } - - $out ; - } ; - - return \$out ; -} - -sub append { - my( $data ) = @_ ; - - my $out ; - - my @data = $data ; - while( defined( my $data = shift @data ) ) { - - if ( ref $data eq 'ARRAY' ) { - push @data, @{$data} ; - next ; - } - - - $out .= ref $data ne 'HASH' ? $data : - "Header\nVal 1: " - . - $data->{val_1} - . - "\n" ; - - my @data = $data->{nest} ; - while( defined( my $data = shift @data ) ) { - - if ( ref $data eq 'ARRAY' ) { - push @data, @{$data} ; - next ; - } - - - $out .= ref $data ne 'HASH' ? $data : - "\n\tLevel: " - . - $data->{level} - . - "\n" ; - - } - - $out .= ref $data ne 'HASH' ? $data : - "\n" ; - - my @data = $data->{opt} ; - while( defined( my $data = shift @data ) ) { - - if ( ref $data eq 'ARRAY' ) { - push @data, @{$data} ; - next ; - } - - - $out .= ref $data ne 'HASH' ? $data : - "\n\tOptional Level: " - . - $data->{level} - . - "\n" ; - - } - - $out .= ref $data ne 'HASH' ? $data : - "\nVal 2: " - . - $data->{val_2} - . - "\nFooter\n" ; - - } - - return \$out ; -} - -sub generate_data { - - my( $outer_size, $inner_size ) = @_ ; - - my @outer_data ; - - for my $outer ( 1 .. $outer_size ) { - - my @inner_data ; - - for my $inner ( 1 .. $inner_size ) { - - push @inner_data, { - - val_1 => ($outer x 2), - val_2 => ($inner x 3), - nest => { - level => "$outer-$inner", - }, - $inner % 2 ? () : ( - - opt => { - level => "$outer-$inner", - }, - ), - } ; - } - - push @outer_data, [@inner_data] ; - } - - return \@outer_data ; -} diff --git a/bench_all.pl b/bench_all.pl deleted file mode 100644 index 42b5560..0000000 --- a/bench_all.pl +++ /dev/null @@ -1,123 +0,0 @@ -#!/usr/bin/env perl - -use strict; -use warnings; - -use Template::Teeny; -use Template::Simple; -use Template::Teeny::Stash; -use Template; - -my $iter = shift || -2 ; - -use Benchmark qw(:hireswallclock cmpthese); -basic: { - - my $ts = Template::Simple->new() ; - $ts->add_templates( { bench => 'hehe [% name %]' } ) ; - - my $tsc = Template::Simple->new() ; - $tsc->add_templates( { bench => 'hehe [% name %]' } ) ; - $tsc->compile( 'bench' ) ; - - my $tt = Template::Teeny->new({ include_path => ['t/tpl'] }); - my $stash = Template::Teeny::Stash->new({ name => 'bob' }); - - my $t = Template->new({ INCLUDE_PATH => 't/tpl', COMPILE_EXT => '.tc' }); - my $out; - open my $fh, '>/dev/null'; - - $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' } ); - } - - print "Very simple interpolation:\n"; - cmpthese( $iter, { teeny => \&teeny, template_toolkit => \&plain, - simple => \&simple, ts_compiled => \&ts_compiled }) ; -} - -some_looping_etc: { - -my $tmpl = < - [% title %] - -
    - [% SECTION post %] -
  • -

    [% title %]

    - [% date %] -
  • - [% END %] -
- - -TMPL - - my $ts = Template::Simple->new() ; - $ts->add_templates( { bench2 => $tmpl } ) ; - - my $tsc = Template::Simple->new() ; - $tsc->add_templates( { bench2 => $tmpl } ) ; - $tsc->compile( 'bench2' ) ; - - my $tt = Template::Teeny->new({ include_path => ['t/tpl'] }); - my $stash = Template::Teeny::Stash->new({ title => q{Bobs Blog} }); - - 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); - - my $t = Template->new({ INCLUDE_PATH => 't/tpl', COMPILE_EXT => '.tc' }); - my $out; - open my $fh, '>/dev/null'; - - my $tt_vars = { - title => 'Bobs Blog', - posts => [ - { title => 'hehe', date => 'Today' }, - { date => '3 Days ago', title => 'Something new' }, - ], - }; - teeny2(); - plain2(); - - sub teeny2 { - $tt->process('bench2-teeny.tpl', $stash, $fh); - } - sub plain2 { - $t->process('bench2-tt.tpl', $tt_vars, $fh); - } - - sub simple2 { - $ts->render('bench2', $tt_vars ); - } - - sub ts_compiled2 { - $tsc->render('bench2', $tt_vars ); - } - - print "\nLoop and interpolation:\n"; - cmpthese( $iter, { teeny => \&teeny2, template_toolkit => \&plain2, - simple => \&simple2, ts_compiled => \&ts_compiled2 }) ; - -} - - - - diff --git a/comp.pl b/comp.pl deleted file mode 100644 index c1281c0..0000000 --- a/comp.pl +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/local/bin/perl - -use strict ; -use warnings ; - -use Template::Simple ; - -my $tmpl = Template::Simple->new() ; - -$tmpl->add_templates( { ddd => < [ - { - nest => { - bar => 'xxx', - }, - }, - { - nest => { - bar => 'yyy', - }, - }, - { - nest => { - bar => 'zzz', - }, - }, - ], -) ; - -$tmpl->compile('foo') ; -#$tmpl->compile('fooz') ; - -#my $rendered = $tmpl->render('foo', { foo => 2, bar => 'xxx' } ) ; - -#print "REND [$$rendered]\n" ; - -$tmpl->compile('ddd') ; -my $rendered = $tmpl->render( 'ddd', $data{ddd} ) ; - -print "REND [$$rendered]\n" ; - -print $tmpl->get_source( 'ddd' ) ; - -exit ; diff --git a/extras/bench_new.pl b/extras/bench_all.pl old mode 100755 new mode 100644 similarity index 75% rename from extras/bench_new.pl rename to extras/bench_all.pl index 24bd979..642b40b --- a/extras/bench_new.pl +++ b/extras/bench_all.pl @@ -24,6 +24,7 @@ my $template_info = [ simple => 'hehe [% name %]', toolkit => 'hehe [% name %]', teeny => 'hehe [% name %]', + tiny => 'hehe [% name %]', }, { name => 'nested', @@ -76,18 +77,30 @@ SIMPLE [% title %] -
    - [% FOREACH post = posts %] +
      [% FOREACH post = posts %]
    • [% post.title %]

      [% post.date %] -
    • - [% END %] + [% END %]
    TOOLKIT + tiny => < + [% title %] + +
      [% FOREACH post IN posts %] +
    • +

      [% post.title %]

      + [% post.date %] +
    • [% END %] +
    + + +TINY + teeny => < [% title %] @@ -176,8 +189,9 @@ my $benches = [ my $name = $info->{name} ; my $results ; - open my $fh, '>', \$results or - die "can't open string for output" ; +# open my $fh, '>', \$results or +# open my $fh, '>', '/dev/null' or +# die "can't open string for output" ; mkdir 'tpl' ; write_file( "tpl/$name.tpl", $template ) ; @@ -210,10 +224,7 @@ my $benches = [ #print Dumper $stash ; $bench->{render} = - sub { - $obj->process("$name.tpl", $stash, $fh ); - $bench->{result} = $results ; - } + sub { $obj->process("$name.tpl", $stash ); } }, verify => sub { @@ -221,6 +232,53 @@ my $benches = [ $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() ; @@ -304,14 +362,11 @@ load_menus.pl [--verify | -v] [--iterations | -i ] =head1 DESCRIPTION - --rid | -r Select the restaurant ID to be fetched. - Can be a comma separated list of rids. - 'ALL' will select all the valid - ID's from a source. This is - required (unless is set - to 'ALL'. - - [--file | -f] Load the XML from files. The file is + --verify | -v Verify rendered output is correct + --iterations | -i Iteration count passed to cmpthese + Default is -2 (seconds of cpu time) + --templaters | -t Comma separated list of templaters + to run in this benchmark [--help | ?] Print this help text diff --git a/extras/cookbook.pl b/extras/cookbook.pl new file mode 100644 index 0000000..f48b7b5 --- /dev/null +++ b/extras/cookbook.pl @@ -0,0 +1,424 @@ +#!/usr/bin/perl + +use strict ; +use warnings ; +use lib '../lib' ; + +use File::Slurp ; + +=head1 Template::Simple Cookbook + +This cookbook contains examples of idioms and best practices when +using the Template::Simple module. It will illustrate all the the +features of this module and show various combinations of code to get +the job done. Send any requests for more examples to +Etemplate@stemsystems.comE. Read the source code to see the +working examples or you can run this script to see all the +output. Each example has its title printed and rendered templates are +printed with a KEY: prefix and delimited with []. + +By combining these techniques you can create and built complex +template applications that can do almost any task other templaters can +do. You will be able to share more code logic and templates as they +are totally isolated and independent from each other. + +=head2 Use Scalar References + +When passing text either as templates or in data tree elements, it is +generally faster to use scalar references than plain scalars. T::S can +accept text either way so you choose the style you like best. Most of +the examples here will use scalar references. Note that passing a +scalar reference to the new() constructor as the template will force +that to be a template and not a template name so no lookup will +occur. T::S always treats all text values as read only and never +modifies incoming data. + +=cut + +use Template::Simple ; +my $ts = Template::Simple->new() ; +my $template ; + + +=head1 Token Expansion + +The simplest use of templates is replacing single tokens with +values. This is vry similar to interpolation of scalar variables in a +double quoted string. The difference is that the template text can +come from outside the program whereas double quoted strings must be in +the code (eval STRING doesn't count). + +To replace tokens all you need is a template with token markups +(e.g. C<[% foo %]>) and a hash with those tokens as keys and the +values with which to replace them. Remember the top level template is +treated as an unnamed chunk so you can pass a hash reference to +render. + +=cut + +print "\n******************\nToken Expansion\n******************\n\n" ; + +$template = <render( $template, + { + token => 'markup', + foo => 'this', + bar => 'so will this', + } +) ; + +print "TOKEN EXPANSION: [${$token_expansion}]\n" ; + +=head1 Token Deletion + +Sometimes you want to delete a token and not replace it with text. All +you need to do is use the null string for its data. Altenatively if +you are rendering a chunk with a hash (see below for more examples) +you can just not have any data for the token and it will also be +deleted. Both styles are shown in this example. + +=cut + +print "\n******************\nToken Deletion\n******************\n\n" ; + +$template = <render( $template, + { + token => '', + } +) ; + +print "TOKEN DELETION: [${$token_deletion}]\n" ; + + +=head1 Named Templates + +You can pass a template directly to the C method or pass in +its name. A named template will be searched for in the object cache +and then in the C directories. Templates can be loaded +into the cache with in the new() call or added later with the +C method. + +=cut + +print "\n******************\nNamed Templates\n******************\n\n" ; + +$ts = Template::Simple->new( + templates => { + foo => <render( 'foo', { data => 'lots of foo' } ) ; + +$ts->add_templates( { bar => <render( 'bar', { data => 'some bar' } ) ; + +print "FOO TEMPLATE: [${$foo_template}]\n" ; +print "BAR TEMPLATE: [${$bar_template}]\n" ; + +=head1 Include Expansion + +You can build up templates by including other templates. This allows a +template to be reused and shared by other templates. What makes this +even better, is that by passing different data to the included +templates in different renderings, you can get different results. If +the logic was embedded in the template you can't change the rendering +as easily. You include a template by using the C<[%include name%]> +markup. The name is used to locate a template by name and its text +replaces the markup. This example shows a single include in the top +level template. + +=cut + +print "\n******************\nInclude Expansion\n******************\n\n" ; + +$ts = Template::Simple->new( + templates => { + top => <>text +TOP + other => <render( 'top', {} ) ; + +print "INCLUDE TEMPLATE: [${$include_template}]\n" ; + +=head1 Template Paths + +You can search for templates in files with the C option +to the constructor. If a named template is not found in the object +cache it will be searched for in the directories listed in the +C option. If it is found there, it will be loaded into +the object cache so future uses of it by name will be faster. The +default value of C option is C. Templates must +have a suffix of C<.tmpl>. This example makes a directory called +'templates' and a template file named C. The second example +makes a directory called C and puts a template in there and +sets. Note that the option value must be an array reference. + +=cut + +print "\n******************\nSearch Dirs\n******************\n\n" ; + +my $tmpl_dir = 'templates' ; +mkdir $tmpl_dir ; +write_file( "$tmpl_dir/foo.tmpl", <new() ; +my $foo_file_template = $ts->render( 'foo', { dir => 'templates' } ) ; + +print "FOO FILE TEMPLATE: [${$foo_file_template}]\n" ; + +unlink "$tmpl_dir/foo.tmpl" ; +rmdir $tmpl_dir ; + +###### + +my $cook_dir = 'cookbook' ; +mkdir $cook_dir ; +write_file( "$cook_dir/bar.tmpl", <new( search_dirs => [$cook_dir] ) ; +my $bar_file_template = $ts->render( 'bar', { dir => 'directory' } ) ; + +print "BAR FILE TEMPLATE: [${$bar_file_template}]\n" ; + +unlink "$cook_dir/bar.tmpl" ; +rmdir $cook_dir ; + +=head1 Named Chunk Expansion + +The core markup in T::S is called a chunk. It is delimited by paired +C and C markups and the text in between them is the +chunk. Any chunk can have multiple chunks inside it and they are named +for the name in the C and C markups. That name is used to +match the chunk with the data passed to render. This example uses the +top level template (which is always an unnamed chunk) which contains a +nested chunk which has a name. The data passed in is a hash reference +which has a key with the chunk name and its value is another hash +reference. So the nested chunk match up to the nested hashes. + +=cut + +print "\n******************\nNested Chunk Expansion\n******************\n\n" ; + +$ts = Template::Simple->new( + templates => { + top => <> chunk +TOP + nested => <render( 'top', + { + nested => { + token => 'nested value', + one => 'value from the data', + } +} ) ; + +print "NESTED TEMPLATE: [${$nested_template}]\n" ; + +=head2 Boolean Chunk + +The simplest template decision is when you want to show some text or +nothing. This is done with an empty hash reference or a null string +value in the data tree. The empty hash reference will cause the text +to be kept as is with all markups removed (replaced by the null +string). A null string (or a reference to one) will cause the text +chunk to be deleted. + +=cut + +print "\n******************\nBoolean Text\n******************\n\n" ; + +$template = \<render( $template, { boolean => {} } ) ; +my $deleted = $ts->render( $template, { default => \'' } ) ; + +print "KEPT: [${$boolean_kept}]\n" ; +print "DELETED: [${$deleted}]\n" ; + +=head2 Default vs. Overwrite Text + +The next step up from boolean text is overwriting a default text with +another when rendering. This is done with an empty hash reference or a +scalar value for the chunk in the data tree. The empty hash reference +will cause the default text to be kept as is with all markups removed +(replaced by the null string). A scalar value (or a scalar reference) +will cause the complete text chunk to be replaced by that value. + +=cut + +print "\n******************\nDefault vs. Overwrite Text\n******************\n\n" ; + +$template = \<render( $template, { default => {} } ) ; +my $overwrite = $ts->render( $template, { default => \<render( $template, { yes_text => {} } ) ; +my $no_shown = $ts->render( $template, { + yes_text => '', + no_text => {} +} ) ; + +print "YES: [${$yes_shown}]\n" ; +print "NO: [${$no_shown}]\n" ; + +=head1 List Chunk Expansion + +T::S has no list markup because of the unique way it handles data +during rendering. When an array reference is matched to a chunk, the +array is iterated and the chunk is then rendered with each element of +the array. This list of rendered texts is concatenated and replaces +the original chunk in the template. The data and the logic that +creates the data controls when a template chunk is repeated. This +example shows the top level (unnamed) template being rendered with an +array of hashes. Each hash renders the chunk one time. Note that the +different results you get based on the different hashes in the array. + +=cut + +print "\n******************\nList Chunk Expansion\n******************\n\n" ; + +$ts = Template::Simple->new( + templates => { + top_array => <render( 'top_array', [ + { + count => 'first', + maybe => {}, + }, + { + count => 'second', + }, + { + count => 'third', + maybe => {}, + }, +] ) ; + +print "TOP_ARRAY: [${$top_array}]\n" ; + + +=head1 Separated List Expansion + +A majorly used variation of data lists are list with a separator but +not one after the last element. This can be done easily with T::S and +here are two techniques. The first one uses a token for the separator +in the chunk and passes in a hash with the delimiter string set in all +but the last element. This requires the code logic to know and set the +delimiter. The other solution lets the template set the delimiter by +enclosing it in a chunk of its own and passing an empty hash ref for +the places to keep it and nothing for the last element. Both examples +use the same sub to do this work for you and all you need to do is +pass it the token for the main value and the seperator key and +optionally its value. You can easily make a variation that puts the +separator before the element and delete it from the first element. If +your chunk has more tokens or nested chunks, this sub could be +generalized to modify a list of hashes instead of generating one. + +=cut + +print "\n******************\nSeparated List Expansion\n******************\n\n" ; + + +sub make_separated_data { + my( $token, $data, $delim_key, $delim ) = @_ ; + +# make the delim set from the template (in a chunk) if not passed in +# an empty hash ref keeps the chunk text as is. + + $delim ||= {} ; + + my @list = map +{ $token => $_, $delim_key => $delim, }, @{$data} ; + +# remove the separator from the last element + + delete $list[-1]{$delim_key} ; + + return \@list ; +} + +my @data = qw( one two three four ) ; + +$ts = Template::Simple->new( + templates => { + sep_tmpl => < <render( 'sep_tmpl', + make_separated_data( 'count', \@data, 'sep', '--' ) ) ; + +my $sep_data = $ts->render( 'sep_data', + make_separated_data( 'count', \@data, 'sep', {} ) ) ; + +print "SEP_DATA: [${$sep_data}]\n" ; +print "SEP_DATA: [${$sep_data}]\n" ; + +exit ; diff --git a/s5-blank.zip b/s5-blank.zip deleted file mode 100644 index d9c820e..0000000 Binary files a/s5-blank.zip and /dev/null differ diff --git a/t/common.pm b/t/common.pm index d61d67c..b730f69 100644 --- a/t/common.pm +++ b/t/common.pm @@ -3,89 +3,102 @@ use Test::More ; use Template::Simple ; +use Data::Dumper ; + sub template_tester { my( $tests ) = @_ ; # plan for one expected ok() call per test - plan( tests => scalar @{$tests} ) ; + plan( tests => scalar @{$tests} * 2 ) ; my( $obj, $tmpl ) ; # loop over all the tests - foreach my $test ( @{$tests} ) { + foreach my $compiled ( 0, 1 ) { - if ( $test->{skip} ) { - ok( 1, "SKIPPING $test->{name}" ) ; - next ; - } + foreach my $test ( @{$tests} ) { - unless( $obj && $test->{keep_obj} ) { + $test->{name} .= ' - compiled' if $compiled ; + + if ( $test->{skip} ) { + ok( 1, "SKIPPING $test->{name}" ) ; + next ; + } + + if ( $test->{compile_skip} && $compiled ) { + ok( 1, "SKIPPING $test->{name}" ) ; + next ; + } + + unless( $obj && $test->{keep_obj} ) { # if there is no kept object, we will constuct one - $obj = eval { - Template::Simple->new( - %{ $test->{opts} || {} } - ) ; - } ; + $obj = eval { + Template::Simple->new( + %{ $test->{opts} || {} } + ) ; + } ; print $@ if $@ ; # check for expected errors # no errors in new() to catch (yet) - } + } - $test->{obj} = $obj ; + $test->{obj} = $obj ; # see if we use the test's template or keep the previous one - $tmpl = $test->{template} if defined $test->{template} ; + $tmpl = $test->{template} if defined $test->{template} ; +#print "TMPL [$tmpl]\n" ; # run any setup sub before this test. this can is used to modify the # object for this test (e.g. delete templates from the cache). - if( my $pretest = $test->{pretest} ) { + if( my $pretest = $test->{pretest} ) { + $pretest->($test) ; + } - $pretest->($test) ; - } +#print Dumper $obj if $test->{dump} ; -# get any existing template object + if ( $compiled ) { -# render the template and catch any fatal errors + my $tmpl_name = 'test' ; + $obj->add_templates( {$tmpl_name => $tmpl} ) ; + eval { $obj->compile( $tmpl_name ) } ; +#print "ERR $@\n" ; + + next if check_error( $test ) ; + } - my $rendered = eval { - $obj->render( $tmpl, $test->{data} ) ; - } ; +# get any existing template object +# render the template and catch any fatal errors -#print "ERR $@\n" if $@; + my $rendered = eval { + $obj->render( $tmpl, $test->{data} ) ; + } ; # if we had an error and expected it, we pass this test - if ( $@ ) { - - if ( $test->{error} && $@ =~ /$test->{error}/ ) { + next if check_error( $test ) ; - ok( 1, $test->{name} ) ; + if( my $posttest = $test->{posttest} ) { + $posttest->($test) ; } - else { - print "unexpected error: $@\n" ; - ok( 0, $test->{name} ) ; - } - next ; - } # see if the expansion was what we expected - my $ok = ${$rendered} eq $test->{expected} ; + my $ok = ${$rendered} eq $test->{expected} ; -# dump any bad expansions +# dump any bad renderings - print <{name} ) ; + ok( $ok, $test->{name} ) ; + } } } +sub check_error { + + my( $test ) = @_ ; + + if ( $@ ) { +#print "ERR $@\n" ; + if ( $test->{error} && $@ =~ /$test->{error}/ ) { + + ok( 1, $test->{name} ) ; + } + else { + + print "unexpected error: $@\n" ; + ok( 0, $test->{name} ) ; + } + + return 1 ; + } + + return ; +} + 1 ; diff --git a/t/error.t b/t/error.t index 1579882..b787300 100644 --- a/t/error.t +++ b/t/error.t @@ -4,9 +4,9 @@ use lib qw(t) ; use common ; my $tests = [ - { - name => 'unknown data type', + name => 'unknown template data type', + compile_skip => 1, opts => {}, data => qr//, template => < qr/unknown template data/, }, - { name => 'missing include', skip => 0, data => {}, - template => '[%INCLUDE foo%]', + template => '[%INCLUDE foox%]', error => qr/can't find/, }, - { name => 'code data', + compile_skip => 1, skip => 0, data => sub { return '' }, template => 'bar', error => qr/data callback/, }, - - ] ; template_tester( $tests ) ; diff --git a/t/include.t b/t/include.t index 4352416..d7ced74 100644 --- a/t/include.t +++ b/t/include.t @@ -26,12 +26,10 @@ BAR ) ; my $tests = [ - { name => 'simple include', skip => 0, opts => { - templates => { 'foo' => 'bar', } @@ -67,7 +65,6 @@ my $tests = [ template => '[%INCLUDE foo%] [%INCLUDE bar%] [%INCLUDE quux%]', expected => 'foo is here bar is too quux is on the drums', }, - { name => 'missing include', skip => 0, @@ -76,12 +73,11 @@ my $tests = [ pretest => sub { $_[0]{obj}->delete_templates() }, error => qr/can't find/, }, - { name => 'load include files', skip => 0, opts => { - include_paths => [ qw( + search_dirs => [ qw( templates templates/deeper templates/deeper/deepest @@ -115,13 +111,15 @@ EXPECTED name => 'delete covering file', skip => 0, opts => { - include_paths => [ qw( + search_dirs => [ qw( templates templates/deeper templates/deeper/deepest ) ], }, pretest => sub { unlink 'templates/deeper/BAR.tmpl' }, + posttest => sub { write_tmpl_files() }, + data => {}, expected => <