Problems with template toolkit and modperl
Scott Penrose
scottp at dd.com.au
Sun Dec 7 16:24:49 CST 2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Wednesday, Dec 10, 2003, at 01:01 Australia/Melbourne, Gerard wrote:
> Hi everyone,
>
> I am experiencing some troubles with Template Toolkit+mod_perl
> and was
> wondering if anyone had seen this behavior and knows how to fix it.
>
> Within a mod_perl handler{}, I am calling a new Template and
> processing some
> object data. Now, outside of mod_perl, just using a normal perl
> script using
> the same template as I use in the mod_perl module, I can get this
> working.
> Within mod_perl, it will not work!
>
> I have narrowed it down to that fact that if I unbless the 'windows'
> objects
> in the code below, it gives me the desired results, but this is
> inefficient
> so I'd like it to be working properly!
>
> This is what the data structure looks like:
>
> my $data = {
> 'windows' => [
> bless( {
> 'name' => 'blah',
> 'buttons' => [
> {
> 'name' =>
> 'frank',
> 'image' =>
> 'whatever'
> }
> ],
> 'foo' => 'bar',
> }, 'Some::Object' ),
> bless( {
> 'name' => 'blah2',
> 'foo' => 'bar2'
> }, 'Some::Object' ),
> ]
> };
>
>
> Here is the template code:
>
> [% FOREACH window = windows %]
> [% FOREACH button = window.buttons %]
> [% button.name %]
> [% button.image %]
> [% END %]
> [% window.name %]
> [% END %]
>
>
> This should give me:
> frank
> whatever
> blah
> blah2
>
> But I only get:
> blah
> blah2
>
> It refuses to access to buttons entry.
>
> My test script outside of mod_perl gives me the correct result.
>
> Any ideas?
There is nothing obvious here, it looks really good.
However there is one suggestions I can think of which is something to
do with the fact that they are blessed. Maybe Template Toolkit is on
with no execute code - so maybe it won't access blessed objects - I
have no idea if this is true.
Another thing where I have got stuck is when extra data is included by
something else, thus overwritting your variable.
However I do have one suggestion which will help you debug it... Use
Data Dumper in Template Toolkit.
[% USE Dumper %]
[% Dumper.dump_html(windows) %]
Or if plain text, just drop _html
See what is in windows. You can then of course walk through it too.
Tell us if you find anything.
Scooter
- --
Scott Penrose
VP in charge of Pancakes
http://linux.dd.com.au/
scottp at dd.com.au
Dismaimer: If you receive this email in error - please eat it
immediately to prevent it from falling into the wrong hands.
Please do not send me Word or PowerPoint attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (Darwin)
Comment: For info see http://www.gnupg.org
iD8DBQE/06i1DCFCcmAm26YRAsDRAKChnd7BWoZPHjZxDSqnnRsV3wbySwCgnj73
O9RJqR7KhOha6/hIUjaaaOA=
=QI+6
-----END PGP SIGNATURE-----
More information about the Melbourne-pm
mailing list