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


In reply to Re: HTML::Tempate::Dot by rhesa
in thread Using loops with HTML::Template::Dot by debiandude

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.