Re: [Templates] Correct replace vmethod

2006-02-01 Thread Josh Rosenbaum
Sergey Martynoff wrote: I have created a simple test, which compares results of native perl s/// (via eval) and proposed template 'replace' vmethod. After thinking a bit, I understand that trying to recreate perl s/// behavior in details is a bad idea. I think that reasonable level of details i

Re: [Templates] Vmethods to add to 2.15

2006-02-01 Thread Josh Rosenbaum
Sergey Martynoff wrote: But what about support for backslash-escaped '$' sign in replace string? It seems to be achieved quite easily, changind the line where actual replace takes place: $matched =~ s/\$$i/$backref/g; with this: $matched =~ s/(? I saw this in Paul's cod

RE: [Templates] Correct replace vmethod

2006-02-01 Thread Sergey Martynoff
> I have created a simple test, which compares results of native > perl s/// (via eval) and proposed template 'replace' vmethod. After thinking a bit, I understand that trying to recreate perl s/// behavior in details is a bad idea. I think that reasonable level of details is simulating perl's $1

Re: [Templates] Vmethods to add to 2.15

2006-02-01 Thread Josh Rosenbaum
[EMAIL PROTECTED] wrote: Here is another code snippet that you might consider. It has the unfortunate item of needing to be copied twice for global. But it does handle $10. It also handles $10 more similarly to Perl. The problem is that if I have $10 in my string - but I have less than 10 p

Re: [Templates] Correct replace vmethod

2006-02-01 Thread Randal L. Schwartz
> "Sergey" == Sergey Martynoff <[EMAIL PROTECTED]> writes: Sergey> There are other issues with backslashes - perl handles \1-\9 as Sergey> $1-$9, but \10 and so on are handled as octal character code (as Sergey> in double-quoed strings). ... unless there are ten or more capturing parens, in w

[Templates] Correct replace vmethod

2006-02-01 Thread Sergey Martynoff
> So with your blessing, I'll include the following as the new replace() > virtual method. I have created a simple test, which compares results of native perl s/// (via eval) and proposed template 'replace' vmethod. It seems that we still have a lot of problems with "last" version of replace. The

RE: [Templates] Vmethods to add to 2.15

2006-02-01 Thread Sergey Martynoff
> I was also able to re-write it using a loop (tail-recursion style) > rather than recursively calling itself. Although I preferred the > elegance of your recursive approach, this way makes it a little easier > to patch directly into $Template::Stash::SCALAR_OPS without having to > create a sep

Re: [Templates] Finding mtime of top-level template

2006-02-01 Thread Gavin Henry
> Gavin Henry wrote: >> So I think the best option is to use [% template.modtime %], but how can >> I >> convert from epoch from within a template? > > Hi Gavin, > > This should do what you want: > > [% USE date %] > [% date.format(template.modtime) %] > > Cheers > A Hey, thanks ;-) > > > __

Re: [Templates] Vmethods to add to 2.15

2006-02-01 Thread Josh Rosenbaum
Andy Wardley wrote: --- sub { my ($scalar, $offset, $length) = @_; return substr($scalar, $offset, $length); }; --- Unfortunately it's not as simple as that. Perl distinguishes between substr($scala

Re: [Templates] Vmethods to add to 2.15

2006-02-01 Thread mail
> Nope, I don't think so. $text is being munged each time around until it > shrinks to zero length and drops out the bottom of the while loop. > > Or have I missed something? You are absolutely right - forgot to view that it is actually munging the $text string. Here is another code snippet tha

Re: [Templates] Template can not use overloaded @{} operator

2006-02-01 Thread Buddy Burden
Gernot, i have the following package definition: package Collection; use overload '@{}' => \&op_deref_array; : : i can not see the 'x' in my output. It seems that the overloading of the @{} operator doesn't work in TT. You are absolutely correct: it doesn't work. I looked into doing a pat

Re: [Templates] Vmethods to add to 2.15

2006-02-01 Thread Andy Wardley
[EMAIL PROTECTED] wrote: > Most likely wanted a g on that - or else you could end up with an infinite > loop depending upon your swap. Nope, I don't think so. $text is being munged each time around until it shrinks to zero length and drops out the bottom of the while loop. Or have I missed some

Re: [Templates] Vmethods to add to 2.15

2006-02-01 Thread mail
> while ($text =~ m/$pattern/) { Most likely wanted a g on that - or else you could end up with an infinite loop depending upon your swap. Also - just wondering - how long has @- been supported - and does it incur any penalties. (Guess I could look this up myself). Paul Seamons _

Re: [Templates] Proposed changes to list.hash and hash.list vmethods

2006-02-01 Thread Andy Wardley
Thanks to everyone for their comments. I've decided that it would indeed be wrong to change the hash.list method without warning, no matter how broken it is or how much better it could be. So the existing behaviour has gone back in, but the method has been documented as likely to change in TT3 a

Re: [Templates] Template can not use overloaded @{} operator

2006-02-01 Thread Larry Leszczynski
Hi Gernot - and where mytemplate.txt looks like [% c %] [% FOREACH x = c %] [% x %] [% END %] Did you mean : [% FOREACH x IN c %] ? Larry ___ templates mailing list templates@template-toolkit.org http://lists.template-toolkit.org/mailman/listinf

Re: [Templates] Encoding patch for Provider

2006-02-01 Thread Bill Moseley
On Wed, Feb 01, 2006 at 12:00:15PM +, Andy Wardley wrote: > Tom Insam wrote: > > will encode the output to utf-8 before writing. Andy - as regards your > > reply, I think it would be a bad idea to assume the same input and > > output template character sets. But that's just me. > > Having look

[Templates] Template can not use overloaded @{} operator

2006-02-01 Thread Gernot Homma
Hello everybody, i have the following package definition: package Collection; use overload '@{}' => \&op_deref_array; sub new { # usual new code my $self = shift; $self->{list} = []; } sub op_deref_array { my $object = shift; return $objec

Re: [Templates] Vmethods to add to 2.15

2006-02-01 Thread Andy Wardley
Nik Clayton wrote: > In the same spirit -- not being able to use backrefs in .replace() is why I > wrote Template::Plugin::Subst. I'm (obviously) biased, but it would seem > to be an appropriate addition to the core. Hi Nik, Sorry I wasn't aware of your module, but it certainly looks like the

Re: [Templates] Encoding patch for Provider

2006-02-01 Thread Andy Wardley
Tom Insam wrote: > will encode the output to utf-8 before writing. Andy - as regards your > reply, I think it would be a bad idea to assume the same input and > output template character sets. But that's just me. Having looked it over, I agree. It's a more complex issue than I first thought. I'v

Re: [Templates] Vmethods to add to 2.15

2006-02-01 Thread Nik Clayton
Josh Rosenbaum wrote: While we're looking at a new release, perhaps now is a proper time to get some vmethods in that seem to be missing for everyone. In the same spirit -- not being able to use backrefs in .replace() is why I wrote Template::Plugin::Subst. I'm (obviously) biased, but it woul

[Templates] Production assistant needed with T2 experience

2006-02-01 Thread Steve Chitwood
Production assistant/manager ­ part time/full time 1+ years web development experience with strong, working knowledge of html, dhtml, css and javascript. Applicant should be highly organized with customer service experience. Experience with Template::toolkit -based sites a really big plus! Thi

Re: [Templates] Finding mtime of top-level template

2006-02-01 Thread Andy Wardley
Gavin Henry wrote: > So I think the best option is to use [% template.modtime %], but how can I > convert from epoch from within a template? Hi Gavin, This should do what you want: [% USE date %] [% date.format(template.modtime) %] Cheers A ___ temp

Re: [Templates] Encoding patch for Provider

2006-02-01 Thread Tom Insam
Bill Moseley wrote: > > > > An unanswered question is should TT also encode output, or should > > setting the output io layer be left to the user? TT already has a 4th option to the 'process' method, an options hash. This takes a 'binmode' key, that can define the output IO layer. eg $tt->pro

Re: [Templates] Vmethods to add to 2.15

2006-02-01 Thread Andy Wardley
Andy Wardley wrote: > I'll give it some more thought. I'll also dig through the archives and > see what other proposals we've had to solve this. Any of those people > who have made suggestions are welcome to chip in again here, to refresh > our memories if nothing else. This is the most promisi

Re: [Templates] Encoding patch for Provider

2006-02-01 Thread Andy Wardley
Bill Moseley wrote: > And would it be smart to have a TEMPLATE_ENCODING config option to > tell Provider how to decode the content if not BOM is not found? Hi Bill, Yes, this is a good idea. > An unanswered question is should TT also encode output, or should > setting the output io layer be lef

Re: [Templates] Vmethods to add to 2.15

2006-02-01 Thread Andy Wardley
Josh Rosenbaum wrote: > While we're looking at a new release, perhaps now is a proper time to get > some vmethods in that seem to be missing for everyone. I have added both > substr for scalars and delete for hash ops, as I'm sure many others have > done. (Actually I just looked at CVS and it lo