Discussion:
[FreeMarker-user] How to refer to sibling variable value ?
Albert Kam
2015-11-11 04:45:09 UTC
Permalink
I couldnt access sibling value from within nested hash item definition.

Non-working example:

<#assign parent={
'sibling1': 'sibling 1',
'sibling2': sibling1 + ' sibling'
}>

or

<#assign parent={
'sibling1': 'sibling 1',
'sibling2': parent.sibling1 + ' sibling'
}>

I had to reserve to a variable outside the hash definition to work:
<#assign val='sibling 1'
parent={
'sibling1': val,
'sibling2': val + ' sibling'
}
Is there a way to refer to sibling value from a hash item definition ?
--
Do not pursue the past. Do not lose yourself in the future.
The past no longer is. The future has not yet come.
Looking deeply at life as it is in the very here and now,
the practitioner dwells in stability and freedom.
(Thich Nhat Hanh)
Daniel Dekany
2015-11-11 08:27:10 UTC
Permalink
There is no way, other than using an external variable. (I haven't
seen such feature in any other language either.)

BTW, this mailing list has been retired. Please use
***@freemarker.incubator.apache.org instead. To subscribe, just write
an empty mail to dev-***@freemarker.incubator.apache.org
(there's no separate user list anymore). Or, use Stack Overflow with
tag "freemarker".
--
Thanks,
Daniel Dekany
Post by Albert Kam
I couldnt access sibling value from within nested hash item definition.
<#assign parent={
'sibling1': 'sibling 1',
'sibling2': sibling1 + ' sibling'
}>>
Post by Albert Kam
or
<#assign parent={
'sibling1': 'sibling 1',
'sibling2': parent.sibling1 + ' sibling'
}>>
Post by Albert Kam
<#assign val='sibling 1'
parent={
'sibling1': val,
'sibling2': val + ' sibling'
}
Is there a way to refer to sibling value from a hash item definition ?
------------------------------------------------------------------------------
Loading...