Changes

Jump to navigation Jump to search
329 bytes removed ,  12:26, 20 December 2013
Line 386: Line 386:     
===== "BROKEN" =====
 
===== "BROKEN" =====
          If any of the program fragments fails to compile or aborts for any
+
If any of the program fragments fails to compile or aborts for any reason, and you have set the "BROKEN" option to a function reference, "Text::Template" will invoke the function.  This function is called the "BROKEN" function.  The "BROKEN" function will tell "Text::Template" what to do next.
          reason, and you have set the "BROKEN" option to a function refer-
  −
          ence, "Text::Template" will invoke the function.  This function is
  −
          called the "BROKEN" function.  The "BROKEN" function will tell
  −
          "Text::Template" what to do next.
     −
          If the "BROKEN" function returns "undef", "Text::Template" will
+
If the "BROKEN" function returns "undef", "Text::Template" will immediately abort processing the template and return the text that it has accumulated so far.  If your function does this, it should set a flag that you can examine after "fill_in" returns so that you can tell whether there was a premature return or not.
          immediately abort processing the template and return the text that
  −
          it has accumulated so far.  If your function does this, it should
  −
          set a flag that you can examine after "fill_in" returns so that you
  −
          can tell whether there was a premature return or not.
     −
          If the "BROKEN" function returns any other value, that value will
+
If the "BROKEN" function returns any other value, that value will be interpolated into the template as if that value had been the return value of the program fragment to begin with.  For example, if the "BROKEN" function returns an error string, the error string will be interpolated into the output of the template in place of the program fragment that cased the error.
          be interpolated into the template as if that value had been the
  −
          return value of the program fragment to begin with.  For example,
  −
          if the "BROKEN" function returns an error string, the error string
  −
          will be interpolated into the output of the template in place of
  −
          the program fragment that cased the error.
     −
          If you don’t specify a "BROKEN" function, "Text::Template" supplies
+
If you don’t specify a "BROKEN" function, "Text::Template" supplies a default one that returns something like Program fragment delivered error ‘‘Illegal division by 0 at template line 37’’(Note that the format of this message has changed slightly since version 1.31.)  The return value of the "BROKEN" function is interpolated into the template at the place the error occurred, so that this template:
          a default one that returns something like
  −
 
  −
                  Program fragment delivered error ‘‘Illegal division by 0 at
  −
                  template line 37’’
  −
          (Note that the format of this message has changed slightly since
  −
          version 1.31.)  The return value of the "BROKEN" function is inter-
  −
          polated into the template at the place the error occurred, so that
  −
          this template:
      
                   (3+4)*5 = { 3+4)*5 }
 
                   (3+4)*5 = { 3+4)*5 }
   −
          yields this result:
+
yields this result:
    
                   (3+4)*5 = Program fragment delivered error ‘‘syntax error at template line 1’’
 
                   (3+4)*5 = Program fragment delivered error ‘‘syntax error at template line 1’’
   −
          If you specify a value for the "BROKEN" attribute, it should be a
+
If you specify a value for the "BROKEN" attribute, it should be a reference to a function that "fill_in" can call instead of the default function.
          reference to a function that "fill_in" can call instead of the
  −
          default function.
      
           "fill_in" will pass a hash to the "broken" function.  The hash will
 
           "fill_in" will pass a hash to the "broken" function.  The hash will

Navigation menu