[Templates-cvs] cvs commit: Template2/docsrc/src/Modules/Template/Plugin String.tt2
cvs@template-toolkit.org
cvs@template-toolkit.org
cvs 06/01/30 16:42:24
Modified: docsrc/src/Modules/Template/Plugin String.tt2
Log:
* added docs for substr() method
Revision Changes Path
1.2 +20 -0 Template2/docsrc/src/Modules/Template/Plugin/String.tt2
Index: String.tt2
===================================================================
RCS file: /template-toolkit/Template2/docsrc/src/Modules/Template/Plugin/String.tt2,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- String.tt2 2001/12/14 11:09:36 1.1
+++ String.tt2 2006/01/30 16:42:23 1.2
@@ -174,6 +174,26 @@
...
[% END %]
+=item substr($offset, $length, $replacement)
+
+Returns a substring starting at $offset, for $length characters.
+
+ [% str = String.new('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
+
=back
=head2 Mutation Methods