Discussion:
[FreeMarker-user] how to use multiple sequence in the same #list element
eharibabu
2016-04-30 10:09:50 UTC
Permalink
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.
Daniel Dekany
2016-04-30 13:47:52 UTC
Permalink
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>
Post by eharibabu
cars = 'audi', 'mercedez', 'ferrari'
fruits = 'apple', 'grapes', 'banana'
audi
apple
mercedes
grapes
ferrari
banana
<#list cars as i, fruits as j>
${i}
${j}
</#list>
basically,my question is how can I use multiple sequences in the same #list
--
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
https://lists.sourceforge.net/lists/listinfo/freemarker-user
--
Thanks,
Daniel Dekany
eharibabu
2016-04-30 14:47:30 UTC
Permalink
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.
Daniel Dekany
2016-04-30 16:41:21 UTC
Permalink
You are using an old FreeMarker version. (The legacy way of putting
this is car_index, which still works, but I recommend updating.)
Post by 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
--
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
https://lists.sourceforge.net/lists/listinfo/freemarker-user
--
Thanks,
Daniel Dekany
eharibabu
2016-05-12 15:02:29 UTC
Permalink
Thank you so much. It worked for me.



--
View this message in context: http://freemarker.624813.n4.nabble.com/how-to-use-multiple-sequence-in-the-same-list-element-tp4655622p4655626.html
Sent from the freemarker-user mailing list archive at Nabble.com.
Continue reading on narkive:
Loading...