sukhwant prafullit
sukhwant prafullit

Reputation: 351

FreeMarker Map of String and List

I'm trying to add sequence as a value in a map:

<#assign client_sequence=['a', 'b']>
{
    clients: ${client_sequence},
    usecase_key: usecase_value,
    other_key: other_value
}

In the above example, client_sequence will be passed from another module which cannot be changed. I have replaced it to illustrate.

I am getting following error:

 For "${...}" content: Expected a string or something automatically convertible to string (number, date or boolean), or "template output" , but this has evaluated to a sequence (wrapper: f.t.SimpleSequence):

==> client_sequence [in nameless template at line 3, column 16]


  FTL stack trace ("~" means nesting-related):

- Failed at: ${client_sequence} [in nameless template at line 3, column 14]

Upvotes: 2

Views: 6698

Answers (1)

Ori Marko
Ori Marko

Reputation: 58772

Use FreeMarker sequence's join built in with comma:

<#assign client_sequence=['a', 'b','c']>
{
    clients: ${client_sequence?join(", ")}
    usecase_key: usecase_value,
    other_key: other_value
}

Concatenates the items of a sequence to a single string, with the given separator.

Upvotes: 4

Related Questions