JMustache 介绍
jmustache 是 Mustache 模板引擎的java实现。
使用方法:
String text = "One, two, {{three}}. Three sir!"; Template tmpl = Mustache.compiler().compile(text); Map<String, String> data = new HashMap<String, String>(); data.put("three", "five"); System.out.println(tmpl.execute(data)); // result: "One, two, five. Three sir!"
示例2:
class Person { public final String name; public Person (String name, int age) { this.name = name; _age = age; } public int getAge () { return _age; } protected int _age; } String tmpl = "{{#persons}}{{name}}: {{age}}{{/persons}}\n"; Mustache.compiler().compile(tmpl).execute(new Object() { Object persons = Arrays.asList(new Person("Elvis", 75), new Person("Madonna", 52)); }); // result: // Elvis: 75 // Madonna: 52
JMustache 官网
https://github.com/samskivert/jmustache
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。