how to use multiple sequence in the same #list element

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

how to use multiple sequence in the same #list element

eharibabu
I have the two sequences as follows:
cars = 'audi', 'mercedez', 'ferrari'
fruits = 'apple', 'grapes', 'banana'

using #list, I would like the output to be printed as follows:

audi
apple

mercedes
grapes

ferrari
banana

I have tried using the following template, but it is throwing error:

<#list cars as i, fruits as j>
${i}
${j}
</#list>

basically,my question is how can I use multiple sequences in the same #list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to use multiple sequence in the same #list element

Daniel Dekany
The best I can think of, assuming that the data-model can't be changed
(so that it contains a list of pairs), is this:

<#list cars as car>
  ${car}
  ${fruits[car?index]}
</#list>


Saturday, April 30, 2016, 12:09:50 PM, eharibabu wrote:

> I have the two sequences as follows:
> cars = 'audi', 'mercedez', 'ferrari'
> fruits = 'apple', 'grapes', 'banana'
>
> using #list, I would like the output to be printed as follows:
>
> audi
> apple
>
> mercedes
> grapes
>
> ferrari
> banana
>
> I have tried using the following template, but it is throwing error:
>
> <#list cars as i, fruits as j>
> ${i}
> ${j}
> </#list>
>
> basically,my question is how can I use multiple sequences in the same #list
>
>
>
> --
> View this message in context:
> http://freemarker.624813.n4.nabble.com/how-to-use-multiple-sequence-in-the-same-list-element-tp4655622.html
> Sent from the freemarker-user mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Find and fix application performance issues faster with Applications Manager
> Applications Manager provides deep performance insights into multiple tiers of
> your business applications. It resolves application problems quickly and
> reduces your MTTR. Get your free trial!
> https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
> _______________________________________________
> FreeMarker-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>

--
Thanks,
 Daniel Dekany


------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to use multiple sequence in the same #list element

eharibabu
Thanks for the reply. I have used the syntax as per your suggestion, but when I am running my code to generate output file, with this test.ftl file, I am getting the below exception. Am I missing anything here?

...in template test.ftl Found index, expecting one of: chunk, is_date, last, root, j_string, round, contains, is_hash, long, float, ends_with, namespace, matches, time, values, seq_last_index_of, uncap_first, byte, substring, is_transform, web_safe, groups, seq_contains, is_macro, index_of, word_list, int, is_method, eval, parent, xml, number, capitalize, if_exists, rtf, node_type, double, is_directive, url, size, default, floor, ceiling, is_boolean, split, node_name, is_enumerable, seq_index_of, is_sequence, sort, is_node, sort_by, left_pad, xhtml, cap_first, interpret, children, node_namespace, chop_linebreak, date, short, last_index_of, is_collection, ancestors, length, trim, datetime, is_string, reverse, c, keys, upper_case, js_string, has_content, right_pad, replace, is_hash_ex, new, is_number, lower_case, is_indexable, string, exists, html, first, starts_with in test.ftl</Cause> </Causes> </Error>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to use multiple sequence in the same #list element

Daniel Dekany
You are using an old FreeMarker version. (The legacy way of putting
this is car_index, which still works, but I recommend updating.)


Saturday, April 30, 2016, 4:47:30 PM, eharibabu wrote:

> Thanks for the reply. I have used the syntax as per your suggestion, but when
> I am running my code to generate output file, with this test.ftl file, I am
> getting the below exception. Am I missing anything here?
>
> ...in template test.ftl Found index, expecting one of: chunk, is_date, last,
> root, j_string, round, contains, is_hash, long, float, ends_with, namespace,
> matches, time, values, seq_last_index_of, uncap_first, byte, substring,
> is_transform, web_safe, groups, seq_contains, is_macro, index_of, word_list,
> int, is_method, eval, parent, xml, number, capitalize, if_exists, rtf,
> node_type, double, is_directive, url, size, default, floor, ceiling,
> is_boolean, split, node_name, is_enumerable, seq_index_of, is_sequence,
> sort, is_node, sort_by, left_pad, xhtml, cap_first, interpret, children,
> node_namespace, chop_linebreak, date, short, last_index_of, is_collection,
> ancestors, length, trim, datetime, is_string, reverse, c, keys, upper_case,
> js_string, has_content, right_pad, replace, is_hash_ex, new, is_number,
> lower_case, is_indexable, string, exists, html, first, starts_with in
> test.ftl&lt;/Cause&gt; &lt;/Causes&gt; &lt;/Error&gt;
>
>
>
> --
> View this message in context:
> http://freemarker.624813.n4.nabble.com/how-to-use-multiple-sequence-in-the-same-list-element-tp4655622p4655624.html
> Sent from the freemarker-user mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Find and fix application performance issues faster with Applications Manager
> Applications Manager provides deep performance insights into multiple tiers of
> your business applications. It resolves application problems quickly and
> reduces your MTTR. Get your free trial!
> https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
> _______________________________________________
> FreeMarker-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>

--
Thanks,
 Daniel Dekany


------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to use multiple sequence in the same #list element

eharibabu
Thank you so much. It worked for me.
Loading...