Smarty templates

2004-02-09 Thread david nicol

Has anyone written a Perl parser for PHP's Smarty template language?


-- 
david nicol
   Hands all over Western culture
   Ruffling feathers and turning eagles into vultures



Re: Testing output to STDOUT and STDERR

2004-02-09 Thread Sam Vilain
On Mon, 09 Feb 2004 14:00, Andy Lester wrote;

While writing tests for some of my code, I was faced with the issue
of capturing what the code sends to STDOUT and STDERR. As I have not
found a module to make it easy, I wrote a trivial code to do it. It
is used like this:
   I'm not sure what you're actually trying to test.  If you're testing
   test modules, look at Test::Builder::Tester.

No, something that ties STDOUT so that code can print to it, and you
can test that the right thing was printed; I've had to do this before,
and ended up not going through the CPAN ropes for this module:

{
package Capture;

sub new {
my $class = shift;
my $self = { stdout =  };
bless $self, $class;
return $self;
}

sub capture_print {
my $self = shift;
$self-{so} = tie(*STDOUT, __PACKAGE__, \$self-{stdout})
or die failed to tie STDOUT; $!;
}

sub release_stdout {
my $self = shift;
delete $self-{so};
untie(*STDOUT);
return $self-{stdout};
}

sub TIEHANDLE {
my $class = shift;
my $ref = shift;
return bless({ stdout = $ref }, $class);
}

sub PRINT {
my $self = shift;
${$self-{stdout}} .= join('', map { defined $_?$_:} @_); 
}

sub PRINTF {
my ($self) = shift;
print STDERR OUCH @_\n;
my ($fmt) = shift;
${$self-{stdout}} .= sprintf($fmt, @_)
if (@_);
}

sub glob {
return \*STDOUT;
}
}

Though, I must say that I prefer his API.  The above was really just a
quick hack based on what I'd extracted out of the ePerl code base.

I'd call it something like IO::Capture if I were to CPAN it.
IO::Seize isn't quite right, but seize is definitely a good Perlish
name for the function.

Note that php has a built-in function to do just this.
-- 
Sam Vilain, sam /\T vilain |T net, PGP key ID: 0x05B52F13
(include my PGP key ID in personal replies to avoid spam filtering)

  Time is an illusion perpetrated by the manufacturers of space.
GRAFFITI





Re: New module Mail::SendEasy

2004-02-09 Thread Simon Cozens
[EMAIL PROTECTED] (Smylers) writes:
 Personally I found Simon's commentary on some mail-sending modules to be
 very useful (and I didn't object to his choice of words: when he found
 something he didn't like he merely said so -- he didn't insult the
 code's author or make allegations about members of the author's familiar
 or anything).

To be honest, I understand that people get very attached to their work, and in
a sense, if you attack their modules, you're attacking them. I'm sure I'd get
upset if someone wrote long scathing criticisms of something I'd spent many
years working on, even if they did start writing a better alternative; such a
criticism can easily be seen to be personal, rather than objective.

Even if it's done with benchmarks.

-- 
It is easier to fight for principles than to live up to them.
-- Alfred Adler


RE: New module Mail::SendEasy

2004-02-09 Thread Orton, Yves
Title: RE: New module Mail::SendEasy





 Even if it's done with benchmarks.


Just curious, but how well does MIME::Lite fare?


Yves





RE: Testing output to STDOUT and STDERR

2004-02-09 Thread Orton, Yves
Title: RE: Testing output to STDOUT and STDERR





 Though, I must say that I prefer his API. The above was really just a
 quick hack based on what I'd extracted out of the ePerl code base.
 
 I'd call it something like IO::Capture if I were to CPAN it.
 IO::Seize isn't quite right, but seize is definitely a good Perlish
 name for the function.
 
 Note that php has a built-in function to do just this.


Its worth noting that this approach wont actually grab everything on the tied filehandles. There are enough ways to bypass the tie that you have to do a lot more than that to get the majority, and even then there is stuff that will still bypass it.

Its very annoying actually that there isnt a reliable and clean way to intercept STDOUT/STDERR properly. (IMO)


Yves








Re: proposed Text::Charnames

2004-02-09 Thread Rodent of Unusual Size
david wrote:
 
 call the module ASCII::TTYish and have it import all the old names
 as constant functions.

er, no existing ASCII:: namespace.  how about Convert::TTYnames ?
-- 
#kenP-)}

Ken Coar, Sanagendamgagwedweinini  http://Golux.Com/coar/
Author, developer, opinionist  http://Apache-Server.Com/

Millennium hand and shrimp!



Re: New module Mail::SendEasy

2004-02-09 Thread Mark Stosberg
On Sun, Feb 08, 2004 at 07:18:38PM +, Smylers wrote:
 
 The Cpan rating thing may help somewhat in this regard -- I will log on
 and give MIME::Lite a good review sometime, honestly!
 
 What would really be useful is a comparison of the various mail-sending
 modules available, listing which features and interfaces each has and in
 which situations it can be used -- in the hope that by sticking to facts
 rather than including opinions it will not be too controversial; perhaps
 the various module authors could even link to it in each of the modules'
 docs?

I think the CPAN rating system could be of further help here as well.
It could be integrated with the search.cpan.org search engine. The
rating could appear on the results page, with top-rated modules
appearing first. So, just searching for a module named mail should be
begin to give you a sensible result. 

This public prominence would also encourage more people to use the
system, I believe.

Mark

--
 . . . . . . . . . . . . . . . . . . . . . . . . . . . 
   Mark StosbergPrincipal Developer  
   [EMAIL PROTECTED] Summersault, LLC 
   765-939-9301 ext 202 database driven websites
 . . . . . http://www.summersault.com/ . . . . . . . .


Re: Smarty templates

2004-02-09 Thread Ed Summers
On Mon, Feb 09, 2004 at 02:58:02AM -0600, david nicol wrote:
 Has anyone written a Perl parser for PHP's Smarty template language?

I haven't, but it sure would be cool if TT3 [1] supported them.

//Ed

[1] http://tt3.template-toolkit.org/



Re: Testing output to STDOUT and STDERR

2004-02-09 Thread Adrian Howard
On Monday, February 9, 2004, at 06:27  pm, Kineticode Billing wrote:

On Feb 9, 2004, at 10:20 AM, Adrian Howard wrote:
[snip]
Cool. Why isn't this on CPAN?
Because:
a) I wasn't happy with the API
b) I'm a lazy SOB and couldn't find the time to sort it out
The new year's resolution may have helped with (b), but Adriano's 
solution looks better anyway :-)

Adrian



Re: Testing output to STDOUT and STDERR

2004-02-09 Thread Adrian Howard
On Monday, February 9, 2004, at 08:27  pm, Andy Lester wrote:

Because:
a) I wasn't happy with the API
b) I'm a lazy SOB and couldn't find the time to sort it out
I'll be glad to help with the second part.  Mail me the parts and I'll
bundle it up all nice for ya.
If you want to play it's at http://www.quietstars.com/perl/

However I still don't think that API is good, and Adriano's solution 
looks like something more generally useful - so I'm not sure that a 
nice bundle is a good idea :-)

Adrian



Re: Testing output to STDOUT and STDERR

2004-02-09 Thread Sam Vilain
On Tue, 10 Feb 2004 00:57, Orton, Yves wrote;

   Its worth noting that this approach wont actually grab everything
   on the tied filehandles.  There are enough ways to bypass the tie
   that you have to do a lot more than that to get the majority, and
   even then there is stuff that will still bypass it.

Yes, that is worth noting; but I'd consider all code that bypasses the
tie to be bugs or an inappropriate test case :-).

I'm just a little curious about the ways that this could happen; see
if you can add to this list.

  a) something grabs the file handle number via fileno(STDOUT) - or
 has a hardcoded `1' for STDOUT - and prints to that directly
 using stdio (now, wouldn't that have to be XS code?)

  b) something uses syswrite(STDOUT)

  c) something written via system() prints to STDOUT

  d) something has already DUP'ed the file handle (ie open FOO,
 STDOUT) and prints to it normally

   Its very annoying actually that there isnt a reliable and clean
   way to intercept STDOUT/STDERR properly. (IMO)

Other than fork and IPC, which bites and doesn't play well with the
test suites... try forking in the middle of a Test::Builder run.
-- 
Sam Vilain, sam /\T vilain |T net, PGP key ID: 0x05B52F13
(include my PGP key ID in personal replies to avoid spam filtering)

Activity is the politician's substitute for achievement.
 - anon.