Re: How to use nested directives?
Daniel Dekany <[email protected]> Tue, 22 May 2012 23:27:32 +0200
| Newsgroups | gmane.comp.text.fmpp |
|---|---|
| Message-ID | <[email protected]> |
Tuesday, May 22, 2012, 4:50:17 PM, Stefan Undorf wrote:
> Hi fmpplers,
>
> I try to generate my menus dynamically and to activate the current menu i=
tem. So I use one directive
> inside another but I do not know how to do it right. The following is tak=
en from the example below:
>
> <#if outFile?index_of(m.item.link) !=3D -1> <!-- m.item.link is unde=
fined -->
This is correct so far, although <#if outFile?cotains(m.item.link)>
would be nicer.
> <#if outFile?index_of(${m.item.link}) !=3D -1> <!-- syntax error -->
(It is an error since ${Expression} only makes sense put directly into
static text or into a string literal. Elsewhere you can you just use
Expression as is.)
> Complete example:
>
> <#assign menus =3D [
> {"item": {"name": "Motive", "link": "motive.html"}},
> {"item": {"name": "Action", "link": "action.html"}},
(I assume there will be something else next to the "item" key in that
map, or else that whole map could be eliminated, of course.)
> ]>
> <#if currentLanguage =3D=3D "es">
> <#assign menus =3D [
> {"item": {"name": "Motivos", "link": "es/motive.html"}},
> {"item": {"name": "Acci=F3n", "link": "es/action.html"}},
> ]>
> </#if>
> <ul class=3D"nav">
> <#list menus as m>
> <li <#if outFile?index_of(m.item.link) !=3D -1>class=3D"activ=
e"</#if>>
> <a href=3D"${m.item.link}">${m.item.name}</a>
> </li>
> </#list> =
> </ul>
>
> How can I access the variable m.item.link in the #if?
Just like you did. Furthermore your above example works for me. So,
some of the items has no "link" in it or it's null. That's what the
error message means.
> Thanks,
> Stefan
-- =
Best regards,
Daniel Dekany
---------------------------------------------------------------------------=
---
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and =
threat landscape has changed and how IT managers can respond. Discussions =
will include endpoint security, mobile security and the latest in malware =
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/