字符串和列表的 FreeMarker 映射
FreeMarker Map of String and List
我正在尝试将序列作为值添加到地图中:
<#assign client_sequence=['a', 'b']>
{
clients: ${client_sequence},
usecase_key: usecase_value,
other_key: other_value
}
在上面的示例中,client_sequence 将从另一个无法更改的模块传递。我已经替换它来说明。
我收到以下错误:
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 [无名模板第 3 行第 16 列]
FTL stack trace ("~" means nesting-related):
- 失败于:${client_sequence} [无名模板第 3 行第 14 列]
使用 FreeMarker 序列的 join 内置逗号:
<#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.
我正在尝试将序列作为值添加到地图中:
<#assign client_sequence=['a', 'b']>
{
clients: ${client_sequence},
usecase_key: usecase_value,
other_key: other_value
}
在上面的示例中,client_sequence 将从另一个无法更改的模块传递。我已经替换它来说明。
我收到以下错误:
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 [无名模板第 3 行第 16 列]
FTL stack trace ("~" means nesting-related):
- 失败于:${client_sequence} [无名模板第 3 行第 14 列]
使用 FreeMarker 序列的 join 内置逗号:
<#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.