HTML templates in spring boot similar to play framework
Asked Answered
H

1

1

I have worked with PlayFramework for Scala. Now I am starting with Spring (Spring Boot) for the first time. Is their any way to make HTML templates similar to Play framework. e.g. passing HTML content into a main(main.scala.html) HTML file.

Hallsy answered 24/1, 2017 at 8:26 Comment(3)
do you search for a template engine for spring boot?Manchu
so, do I have to add template engine to spring?Hallsy
no, you dont. But thymeleaf is common to use with spring boot.Manchu
S
1

Spring framework does not force you to use any particular view technology. You can use anything that can be integrated. The topic is covered in the documentation where you can read about the details on popular choices. However, the most popular is Thymeleaf, which used to be a part of Spring MVC before separation into an independent project. You can find a clear example on how to use it with Spring Boot in the getting started guide.

The templates in Play framework created using Twirl framework are converted into Scala code. You simply pass the data model via template parameter list, just like you do with any method.

In Spring framework you put all date that you want to expose to your view in a so-called model map, which is a simple key-value storage. In the view technology you refer the values using corresponding keys.

Stutsman answered 24/1, 2017 at 9:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.