Reputation: 6883
i have a variable
var1 = {
'*' = > {
'counter' = > {
'default' = > '0',
'description' = > 'test'
}
}
}
in perl template toolkit. How can i access the content of '*' in the template.
[% var1.*.counter %]
does not work because of the symbol is no valid name.
Upvotes: 0
Views: 76
Reputation: 126722
You can define a variable to be equal to *
within the template, and use that instead.
[% star = '*' %]
[% var1.$star.counter.description %]
But I wonder why you have to have an asterisk as a key in the first place? It would be far better to provide a sensible key at the Perl level, perhaps by writing
$vars->{var1}{star} = $vars->{var1}{'*'}
before you call the Template Toolkit.
Upvotes: 6