【发布时间】:2020-10-16 15:27:48
【问题描述】:
我想在 java 中实现一个可以从 mustache 模板调用的 lambda。到目前为止,我只能找到一篇关于这个主题的写得很糟糕的博客文章:https://spring.io/blog/2016/11/21/the-joy-of-mustache-server-side-templates-for-the-jvm。本质上,我有一个模板文件
{{#getContentType}}
{{http-response.headers}}
{{/getContentType}}
方法名为getContentType,它接受一个列表对象http-response.headers,并从键值对中返回值
{
"name": "Content-Type",
"value": "application/json"
}
我什至看过文档:https://github.com/spullara/mustache.java#readmehttps://github.com/spullara/mustache.java#readme,但我仍在努力解决这个问题。任何帮助将不胜感激!
getContentType lambda 的示例输入作为参考
[
{
"name": "Content-Type",
"value": "application/json"
},
{
"name": "Content-Length",
"value": "363"
},
{
"name": "Authorization",
"value": "Bearer bearerToken"
},
{
"name": "Host",
"value": "host"
}
]
没有任何使用 TemplateFunctions 的示例,但文档在这里:http://spullara.github.io/mustache/apidocs/。一个新人很难“得到它”。
【问题讨论】: