forked from spullara/mustachelet
-
Notifications
You must be signed in to change notification settings - Fork 0
Servlet for serving Mustache based templates with backing Java code
fersab/mustachelet
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Mustache gives you a great way to generate HTML, this wraps that up in a Servlet so you can do it quite easily. Here is an example: Backing code (Index.java): @Path("/") @Template("index.html") public class Index { @Controller boolean exists() { return true; } String name() { return "Sam"; } } Template code (index.html): <html> <head> <title>Index</title> </head> <body> Hello, {{name}}! </body> </html> The POST use case is a little more involved. Here is the post mustachelet: @Path("/post(/(.*))?") @Template("post.html") @HttpMethod({GET, POST}) public class Post { @Request(RESPONSE) HttpServletResponse response; @Request(REQUEST) HttpServletRequest request; @Controller(POST) boolean redirectPostData() throws IOException { response.sendRedirect("/post/" + request.getParameter("value")); return false; } @Request(MATCHER) Matcher m; String value() { return m.group(2); } } With its associated template: <html> <head> <title>Post</title> </head> <body> <form method="POST" action="/post"> <input type="text" name="value" value="{{value}}"><input type="submit"> </form> </body> </html>
About
Servlet for serving Mustache based templates with backing Java code
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published