How to refer to sibling variable value ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to refer to sibling variable value ?

Albert Kam
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)

------------------------------------------------------------------------------

_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|

Re: How to refer to sibling variable value ?

Daniel Dekany
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
[hidden email] instead. To subscribe, just write
an empty mail to [hidden email]
(there's no separate user list anymore). Or, use Stack Overflow with
tag "freemarker".

--
Thanks,
 Daniel Dekany


Wednesday, November 11, 2015, 5:45:09 AM, Albert Kam wrote:

> 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 ?
>


------------------------------------------------------------------------------
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user