Dear folks,

I'm pretty new to TT.

I was just creating my first project when I noticed that
virtual method "trim" produces empty output.

I read http://www.template-toolkit.org/docs/manual/VMethods.html
several times but it did not help.
Finally I wrote this test template:

---------8<------------------8<--------------------
chunk:
[% ccard_no = "1234567824683579";
   ccard_no.chunk(4).join
%]
collapse:
[% text = "  The bird\n  is the word" %]
[% text.collapse %]
dquote:
[% quote = 'He said "Oh really?"' %]
[% quote.dquote %]
lower:
[% word = 'BIRD' %]
[% word.lower %]
match:
[% name = 'Larry Wall' %]
[% matches = name.match('(\w+) (\w+)') %]
[% matches.1 %], [% matches.0 %]
repeat:
[% name = 'foo' %]
[% name.repeat(3) %]
replace:
[% name = 'foo, bar & baz' %]
[% name.replace('\W+', '_') %]
remove:
[% name = 'foo, bar & baz' %]
[% name.remove('\W+') %]
substr:
[% str = 'foo bar baz wiz waz woz' %]
[% str.substr(4, 3) %]
squote:
[% tim = "Tim O'Reilly" %]
[% tim.squote %]
trim:
[% text = '  hello  world  ' %]
[% text.trim %]
ucfirst:
[% word = 'bird' %]
[% word.ucfirst %]
upper:
[% word = 'bird' %]
[% word.upper %]
---------8<------------------8<--------------------

All the examples are from the mentioned web page.
(Note: substr is fixed)

This is the output of "tpage --pre_chomp methodtest" command:

---------8<------------------8<--------------------
chunk:1234 5678 2468 3579
collapse:
dquote:
lower:
match:Wall, Larry
repeat:foofoofoo
replace:foo_bar_baz
remove:foobarbaz
substr:bar
squote:
trim:
ucfirst:
upper:
---------8<------------------8<--------------------

Did I miss something or this is some well known bug?

Cheers

Gabor

_______________________________________________
templates mailing list
templates@template-toolkit.org
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to