Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #1 from mremy/add-template-directive-options

Added $Template::Directive::WHILE_MAX option to tpage
  • Loading branch information...
commit 2d08aa6d6f8ea8635141e9d326416920bd3fd117 2 parents 77120a2 + 1914844
Andy Wardley authored January 13, 2012

Showing 1 changed file with 19 additions and 3 deletions. Show diff stats Hide diff stats

  1. 22  bin/tpage
22  bin/tpage
@@ -25,6 +25,7 @@
25 25
 
26 26
 use strict;
27 27
 use Template;
  28
+use Template::Directive;
28 29
 use AppConfig;
29 30
 
30 31
 my $NAME     = "tpage";
@@ -39,8 +40,11 @@ my $config   = read_config($RCFILE);
39 40
 # unshift any perl5lib directories onto front of INC
40 41
 unshift(@INC, @{ $config->perl5lib });
41 42
 
42  
-# get all template_* options from the config and fold keys to UPPER CASE
43  
-my %ttopts   = $config->varlist('^template_', 1);
  43
+# get all template_directive_* options from the config
  44
+my %ttdirectiveopts = $config->varlist('^template_directive_', 1);
  45
+
  46
+# get all template_* (except template_directive_*) options from the config and fold keys to UPPER CASE
  47
+my %ttopts   = $config->varlist('^template_(?!directive_)', 1);
44 48
 my $ttmodule = delete($ttopts{ module });
45 49
 my $ucttopts = {
46 50
     map { my $v = $ttopts{ $_ }; defined $v ? (uc $_, $v) : () }
@@ -58,6 +62,14 @@ else {
58 62
     $ttmodule = $TTMODULE;
59 63
 }
60 64
 
  65
+# load custom Template::Directive configuration
  66
+map {
  67
+  my $v = $ttdirectiveopts{ $_ };
  68
+  if( defined $v ) {
  69
+    ${ $Template::Directive::{ uc $_ } } = $ttdirectiveopts{ $_ }
  70
+  }
  71
+} keys %ttdirectiveopts;
  72
+
61 73
 # add current directory to INCLUDE_PATH
62 74
 unshift(@{ $ucttopts->{ INCLUDE_PATH } }, '.');
63 75
 
@@ -110,7 +122,10 @@ sub read_config {
110 122
         'template_compile_ext|compile_ext=s',
111 123
         'template_compile_dir|compile_dir=s',
112 124
         'template_plugin_base|plugin_base|pluginbase=s@',
113  
-        'perl5lib|perllib=s@'
  125
+        'perl5lib|perllib=s@',
  126
+        'template_directive_debug',
  127
+        'template_directive_pretty',
  128
+        'template_directive_while_max|while_max=i'
114 129
     );
115 130
 
116 131
     # add the 'file' option now that we have a $config object that we 
@@ -166,6 +181,7 @@ Options:
166 181
    --compile_dir=DIR        Directory for compiled template files
167 182
    --perl5lib=DIR           Specify additional Perl library directories
168 183
    --template_module=MODULE Specify alternate Template module
  184
+   --while_max=INTEGER      Change '\$Template::Directive::WHILE_MAX' default
169 185
 
170 186
 See 'perldoc tpage' for further information.  
171 187
 

0 notes on commit 2d08aa6

Please sign in to comment.
Something went wrong with that request. Please try again.