Skip to content

Spring Boot autoconfiguration for JMutsache (web and nonweb template rendering)

Notifications You must be signed in to change notification settings

instaweb/spring-boot-mustache

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot autoconfig support for JMustache (logic-less handlebar style templates).

Currently supported: rendering templates in a standalone app, and via a Spring MVC View and ViewResolver.

Example standalone usage:

@EnableAutoConfiguration
@Configuration
public class Application implements CommandLineRunner {

	@Autowired
	private Mustache.Compiler compiler;

	public void run(String... args) {
		System.out.println(compiler.compile("Hello: {{world}}").execute(
				Collections.singletonMap("world", "World")));
	}
    
}

Example webapp, with template (in classpath:/templates/home.html):

<html>
<head>
<title>{{title}}</title>
</head>
<body>
	<h2>A Message</h2>
	<div>{{message}} at {{time}}</div>
</body>
</html>

application code:

@Configuration
@EnableAutoConfiguration
@Controller
public static class Application {

	@RequestMapping("/")
	public String home(Map<String, Object> model) {
		model.put("time", new Date());
		model.put("message", "Hello World");
		model.put("title", "Hello App");
		return "home";
	}

	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}

}

Run the app and then load the HTML page at http://localhost:8080.

About

Spring Boot autoconfiguration for JMutsache (web and nonweb template rendering)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%