[Templates] Subclassing Template::Stash::XS

Kerry DeZell kdezell@sps.com
Wed, 21 Jun 2006 09:44:20 -0600


This is a multi-part message in MIME format.
--------------040801070303070404050102
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

We were not quite satisfied with the .defined notation and default 
defined behavior when we started using TT.
Though returning an empty string for undefined values is nice for 
outputting simple HTML, it makes it difficult to check if values 
(including hash refs, array refs, and return values from plugin calls 
that wrapper existing perl code) are defined and change logic 
accordingly. Therefore, we created a simple sub-class of Template::Stash 
and implemented an undefined subroutine that returned undef instead of 
the empty string. In conjunction with another plugin that provides 
wrappers for simple perl functions it allows us to easily check if any 
variable is defined or not defined. This was easy to implement and 
worked nicely.

With the arrival of Template::Stash::XS it would be nice to gain any 
performance increase offered. However, sublcassing Template::Stash::XS 
and creating an undefined subroutine does not have the same effect as it 
did when Template::Stash was subclassed.

Is there a way to have the perl undef value returned for undefined 
variables when using Template::Stash::XS?

Thanks

Kerry


--------------040801070303070404050102
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<font face="Helvetica, Arial, sans-serif">We were not quite satisfied
with the .defined notation and default defined behavior when we started
using TT.<br>
Though returning an empty string for undefined values is nice for
outputting simple HTML, it makes it difficult to check if values
(including hash refs, array refs, and return values from plugin calls
that wrapper existing perl code) are defined and change logic
accordingly. Therefore, we created a simple sub-class of
Template::Stash and implemented an undefined subroutine that returned
undef instead of the empty string. In conjunction with another plugin
that provides wrappers for simple perl functions it allows us to easily
check if any variable is defined or not defined. This was easy to
implement and worked nicely.<br>
<br>
With the arrival of Template::Stash::XS it would be nice to gain any
performance increase offered. However, sublcassing Template::Stash::XS
and creating an undefined subroutine does not have the same effect as
it did when Template::Stash was subclassed.<br>
<br>
Is there a way to have the perl undef value returned for undefined
variables when using Template::Stash::XS?<br>
<br>
Thanks<br>
<br>
Kerry<br>
<br>
</font>
</body>
</html>

--------------040801070303070404050102--