Re: [Templates] register vmethods?

2008-08-01 Thread Marc Chantreux
Sean, On Tue, Jul 29, 2008 at 12:13:03AM +0200, Marc Chantreux wrote: hello Sean, I'm afraid it does the same ... I was afraid for nothing: it works fine. Additionnaly, it is very simple to add methods using Template::Plugin::VMethods. many thanks for help regards -- Marc Chantreux

Re: [Templates] register vmethods?

2008-08-01 Thread Marc Chantreux
Josh, On Wed, Jul 30, 2008 at 10:03:14AM -0600, Josh Rosenbaum wrote: More details here: http://template-toolkit.org/docs/modules/Template/Stash/XS.html thanks for explainations and pointing this link! [% notice.field('99'); %] I'd just add a method to the object, do you mean that if

Re: [Templates] register vmethods?

2008-07-30 Thread Josh Rosenbaum
Marc Chantreux wrote: SNIP I have 2 questions about it: i use Template::Stash, so i guess that XS isn't used anymore in my script so i lost performance. is it right? No, the use of the XS stash is determined by: $Template::Config::STASH = 'Template::Stash::XS'; OR: my $stash =

Re: [Templates] register vmethods?

2008-07-30 Thread Sean McAfee
Well, coincidentally I found myself needing to solve the same problem as the OP. I replaced some template inputs that had been plain numbers with objects (implemented in the standard fashion as a reference to a hash) that perform some basic caching, and that reduce to numbers via use overload. I

[Templates] register vmethods?

2008-07-28 Thread Marc Chantreux
hello, I tried to register a vmethod to an object using this way: use strict; use warnings; use Template; use Template::Stash; $Template::Stash::SCALAR_OPS-{field} = sub { my $self = shift; $self-field(@_); } but it doesn't work: $self can't be a reference to be handled by SCALAR_OPS.

Re: [Templates] register vmethods?

2008-07-28 Thread Sean McAfee
On Mon, Jul 28, 2008 at 4:07 AM, Marc Chantreux [EMAIL PROTECTED] wrote: hello, I tried to register a vmethod to an object using this way: use strict; use warnings; use Template; use Template::Stash; $Template::Stash::SCALAR_OPS-{field} = sub { my $self = shift;

Re: [Templates] register vmethods?

2008-07-28 Thread Sean McAfee
On Mon, Jul 28, 2008 at 10:10 AM, Sean McAfee [EMAIL PROTECTED] wrote: On Mon, Jul 28, 2008 at 4:07 AM, Marc Chantreux [EMAIL PROTECTED] wrote: hello, I tried to register a vmethod to an object using this way: use strict; use warnings; use Template; use Template::Stash;

Re: [Templates] register vmethods?

2008-07-28 Thread Marc Chantreux
hello Sean, I'm afraid it does the same ... On Mon, Jul 28, 2008 at 11:26:05AM -0700, Sean McAfee wrote: sub Foo::field { $_[1] } $Template::Stash::HASH_OPS-{foo} = sub { shift-field(@_) }; Template-new-process(\[% x.foo(42) %], { x = bless({ }, 'Foo' }); -- Marc Chantreux BibLibre, expert

Re: [Templates] register vmethods?

2008-07-28 Thread Sean McAfee
On Mon, Jul 28, 2008 at 3:13 PM, Marc Chantreux [EMAIL PROTECTED] wrote: hello Sean, I'm afraid it does the same ... I'm not sure what you mean. Here's a less abbreviated example: use Template; use Template::Stash; use strict; package Object; sub new { my ($class, $addend) = @_;