[bs-120] Support for groovy templates
* Added GroovyTemplate.template() utility and static import in webapp CLI, so
@RequestMapping("/")
@ResponseBody
String home(Model model) {
template "home.html", model
}
renders the template in /templates/home.html
[Fixes #49832753]
This commit is contained in:
25
spring-bootstrap-cli/samples/template.groovy
Normal file
25
spring-bootstrap-cli/samples/template.groovy
Normal file
@@ -0,0 +1,25 @@
|
||||
package org.test
|
||||
|
||||
import static org.springframework.bootstrap.cli.template.GroovyTemplate.template;
|
||||
|
||||
@Component
|
||||
class Example implements CommandLineRunner {
|
||||
|
||||
@Autowired
|
||||
private MyService myService
|
||||
|
||||
void run(String... args) {
|
||||
print template("test.txt", ["message":myService.sayWorld()])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Service
|
||||
class MyService {
|
||||
|
||||
String sayWorld() {
|
||||
return "World"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user