在我的 Play 应用程序中,我有这样的配置:
social {
twitter {
url="https://twitter.com"
logo="images/twitter.png"
}
facebook {
url="https://www.facebook.com"
logo="images/facebook.png"
}
}
我如何遍历所有social
条目以获取url
每个logo
条目?
<table border="0" cellspacing="0" cellpadding="2"><tr>
@configuration.getConfig("social").map { config =>
@for(item <- config.entrySet) {
<td><a href="item.getString("url")">
<img src="@routes.Assets.at("item.getString("logo")").absoluteURL()" width="24" height="24"/></a></td>
}
}
</table>
当然,item.getString
在上面的片段中不起作用......它只是显示了我想要实现的目标。
最终目标是能够添加任何其他社交 URL,而无需修改页面模板。