freemarker-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Dekany <ddek...@freemail.hu>
Subject Re: Question about String Concatenation [FM2]
Date Mon, 06 Mar 2017 16:05:20 GMT
Monday, March 6, 2017, 4:36:12 PM, Ingo Mahnke wrote:

> Hallo,
> one question.
>
> This works:
> <#list imagesLayout?split(";") as x>
>             <table border="0" cellspacing="0" cellpadding="0" style="width:100%">
>                 <tr>
>                     <#list x?split("-") as y>
>                         <#assign s = "image"+y>
>                         <td class="qvImageGalleryImage"><@img
> width="100%" height="185" style="width:100%;" name="${s}"/></td>
>                     </#list>
>                 </tr>
>             </table>
>         </#list>
>
>
>
> Why this will not work:
> <#list imagesLayout?split(";") as x>
>             <table border="0" cellspacing="0" cellpadding="0" style="width:100%">
>                 <tr>
>                     <#list x?split("-") as y>
>                           <td class="qvImageGalleryImage"><@img
> width="100%" height="185" style="width:100%;" name="${"image"+y}"/></td>
>                     </#list>
>                 </tr>
>             </table>
>         </#list>
>
>
> Why I have to use the "assign"?

It should be

   name="image"+y

or

  name="image${y}"

The problem occurs because the @img tag isn't just static like HTML,
so the parameters to it are FTL expressions. "${"image"+y}" isn't a
valid expression (the quotation marks are messed up). "${'image'+y}"
would be valid, but it's not the shortest way.

> Thank you
> Ingo

-- 
Thanks,
 Daniel Dekany


Mime
View raw message