[Petal] [BUG] can't set variables to static values
Fergal Daly
fergal at esatclear.ie
Fri May 23 01:40:16 BST 2003
On Thursday 22 May 2003 15:56, Steve Purkis wrote:
> Yup - auto-vivifying a hash was what I was hoping it would do...
As far as I know, Petal (and TAL) only set variables at the top level. So
trying to set $lang/fu is not supposed to work. I think this makes sense as
it discourages peple from building too much complexity into their templates.
They're pretty much designed to be used as shortcuts so you don't have to
keep typing $big/long/variable/path/expression.
> 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.
I think (4) is actually the correct option. Even if language was a
presentation issue, setting all the variables is not presentation and also
it's messy enough that you don't want to have to think about it and in your
template code.
That said, I don't think language is a presentation issue, at least not in the
same way style and layout are. If you are making something multi-language you
really have three layers
a: backend logic
b: localisation
c: presentation
a: decides what you want to say and produces data, b: checks that data for
anything that needs to be localised to the desired language and c: then takes
the localised strings and data and presents them in the correct layout and
style. In reality a and b are usually merged together because it's usually
easier to localise strings when they are generated than go hunting for them
afterwards. Separating all 3 layers would only be useful if you wanted to
present the same data in several different languages but just generate it
once,
F
More information about the Petal
mailing list