[EMAIL PROTECTED] wrote:
Chad,
thanks for your help! What Jason Gottshall suggested seems to be the simpler
way of doing what I want, but to get to know TT2 better I will try it your way
as well. Thanks! :-)
Oh, I didn't see a reply from him; I'd be interested in learning what he suggested.
Oh... he didn't--*gasp*--reply off-list... DID HE!? :-)
On some mailing lists, people are publicly drawn and quartered for replying
off-list.
Anyhow, it's good to see you got it sorted out!
-----Ursprüngliche Nachricht-----
Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von C. Chad Wallace
Gesendet: Mittwoch, 3. August 2005 22:13
An: [email protected]
Betreff: Re: [Templates] Problem accessing hash-ref-data in a filter (hash ref
gets stringified)
[EMAIL PROTECTED] wrote:
I try to process data from a hash ref in a filter, but it seems to be
"stringified" until it reaches the filter, at least that is how I
interpret the output you can see below.
Basically, instead of the line
HASH(0x84be56c)
I would like to create something like
service_name: src1 dst1 serv1
in the filter.
You should probably use a plugin instead of a filter. I think filters are
intended to be used only on string content. But you can pass any kind of
parameters to a plugin.
To learn how to create a plugin, see the Template::Plugin documentation--it's
pretty simple. Here's your example template rewritten to use a plugin:
[% USE plugin_my = MyPlugin # Create a handle for the plugin %]
[% FOREACH participant IN participants %]
Participant: [% participant.primary_key %]
[% FOREACH service IN participant.services %]
[% plugin_my.process_service( service ) # Pass the structure to the
plugin %]
[% END %]
[% END %]
Thank you for any pointers of what I am doing wrong or of better ways to
achieve what I am trying to do ...
Daniel.
########### OUTPUT ##############
#Dumper:
$VAR1 = {
'service_name' => {
'src' => 'src1',
'srv' => 'serv1',
'dst' => 'dst1'
}
};
# Filter:
GOT: $VAR1 = 'HASH(0x84be56c)';
#Template:
Participant: 1
HASH(0x84be56c)
########### TEMPLATE ##############
[% FOREACH participant IN participants %]
Participant: [% participant.primary_key %]
[% FOREACH service IN participant.services %]
[% service FILTER flt_my %]
[% END %]
[% END %]
[...]
--
C. Chad Wallace, B.Sc.
The Lodging Company
http://skihills.com/
OpenPGP Public Key ID: 0x262208A0
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates