[Templates-cvs] cvs commit: Template2/docsrc/src/Manual VMethods.tt2

cvs@template-toolkit.org cvs@template-toolkit.org


cvs         06/02/01 08:39:01

  Modified:    docsrc/src/Manual VMethods.tt2
  Log:
  * added substr scalar method
  
  Revision  Changes    Path
  1.9       +19 -0     Template2/docsrc/src/Manual/VMethods.tt2
  
  Index: VMethods.tt2
  ===================================================================
  RCS file: /template-toolkit/Template2/docsrc/src/Manual/VMethods.tt2,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- VMethods.tt2	2006/02/01 07:52:01	1.8
  +++ VMethods.tt2	2006/02/01 08:39:01	1.9
  @@ -125,6 +125,25 @@
   
       1,234,567
   
  +=item substr(offset, length, replacement)
  +
  +Returns a substring starting at 'offset', for 'length' characters.
  +
  +    [% str 'foo bar baz wiz waz woz') %]
  +    [% str.substr(4, 3) %]    # bar
  +
  +If 'length' is not specified then it returns everything from the
  +'offset' to the end of the string.
  +
  +    [% str.substr(12) %]      # wiz waz woz
  +
  +If both 'length' and 'replacement' are specified, then the method
  +replaces everything from 'offset' for 'length' characters with
  +$replacement.  The substring removed from the string is then returned.
  +
  +    [% str.substr(0, 11, 'FOO') %]   # foo bar baz
  +    [% str %]                        # FOO wiz waz woz
  +
   =item list
   
   Return the value as a single element list.  This can be useful if you