[Petal] [BUG] can't set variables to static values
Steve Purkis
spurkis at quiup.com
Thu May 22 16:56:34 BST 2003
On Thursday, May 22, 2003, at 03:26 pm, Jean-Michel Hiver wrote:
>> <span petal:if="false: lang">
>> <?var name="set: lang/fu string:1"?>
>> </span>
>>
>> lang-fu: $lang/fu
>>
>> It lets me set lang/fu fine (ie: if I take out the last line, it
>> works). And I've tried variations on the theme to no avail. Any
>> ideas?
>
> I see... Basically you're internally creating a 'lang/fu' hash key, but
> then you can't access this value using $lang/fu because Petal is trying
> to access $hash->{lang}->fu() or $hash->{lang}->{fu}...
Yup - auto-vivifying a hash was what I was hoping it would do...
> Have you tried using $lang\/fu when retrieving the variable?
No, and I wouldn't want to in this situation - this is part of a larger
problem I'm trying to solve, which warrants some explanation:
The idea is that 'lang' can be set from a number of different places
such as $session/language, $view/language, $user/preferred_language,
etc. In the case that 'lang' is not set, I'd like to still be able to
use it as if it were. (ie: access $lang/name without Petal throwing an
error).
These are the possible solutions I've thought of:
1. Use single values for lang attributes (ie: $lang_name vs $lang/name)
2. Create a 'fake' value for lang in the template.
3. Change Petal so that it returns false instead of throwing an error.
4. Move this logic into the back-end.
I'm doing (1) at the moment, and was investigating (2). (3) has
occurred to me in the past, but seems like it might be too much work.
And I'd rather not do (4) because this is a presentation issue and
should be handled in the presentation layer.
-Steve
More information about the Petal
mailing list