in reply to Using loops with HTML::Template::Dot

Hi debiandude,

I wrote HTML::Template::Plugin::Dot, and I'm pretty sure this ought to work. See the t/dot_loop.t test in the distribution. I'll paste it here verbatim:

use Test::More qw(no_plan); use strict; use_ok('HTML::Template::Pluggable'); use_ok('HTML::Template::Plugin::Dot'); use_ok('Test::MockObject'); my $mock = Test::MockObject->new(); $mock->mock( 'some', sub { $mock } ); $mock->mock( 'method', sub { "chained methods work inside tmpl_loop" } + ); my $mock2 = Test::MockObject->new(); $mock2->mock( 'some', sub { $mock2 } ); $mock2->mock( 'method', sub { "chained methods work inside a loop twic +e" } ); my ($output, $template, $result); $template = qq{<tmpl_loop deloop><tmpl_var num><tmpl_var should_be.som +e.method></tmpl_loop>}; # test a simple template my $t = HTML::Template::Pluggable->new( scalarref => \$template, debug => 0 ); eval { $t->param('deloop',[ {should_be => $mock, num => 1}, {should_be => + $mock2, num => 2} ]); $output = $t->output; }; SKIP: { skip "HTML::Template subclassing bug for tmpl_loop support. See: h +ttp://rt.cpan.org/NoAuth/Bug.html?id=14037", 2 if $@; like($output ,qr/chained methods work inside tmpl_loop/); like($output ,qr/chained methods work inside a loop twice/); }
As you can see here, I'm passing in an arrayref directly. Which version of HTML::Template do you have? What does this test result in for you?

We use HT::Dot extensively in our company, in combination with CGI::Application and Class::DBI. It works okay, but I'd be the first to admit that it can't compete with the Template Toolkit. HT::Dot is limited in what it can accomplish, mainly because of the way HTML::Template itself is structured. It was easy to put some form of dot-expression parsing inside param(), but it would be very difficult to actually hook it into H::T's parsing code. If I had to muck around in there, I'd be creating a real fork of HTML::Template. And that would be futile, since TT2 is already so much better.

Rhesa

Replies are listed 'Best First'.
Re^2: HTML::Tempate::Dot
by debiandude (Scribe) on Jun 09, 2006 at 12:03 UTC

    Hey rhesa,

    Thanks for the quick response. I ran the test and all five of them passed. I am thinking maybe it might be something to do with the fact that I am using HTML::Template::Plugin::Dot though CGI::Application::Plugin::HTDot? I am going to fire up CPAN and check to see if I have the latest versions. If not I will update and see if it works then.