feat: repeating dynamic testimonial section
This commit is contained in:
@@ -6,6 +6,7 @@ import cask.main.Routes
|
||||
import org.thymeleaf.context.Context
|
||||
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver
|
||||
import org.thymeleaf.TemplateEngine
|
||||
import scala.beans.BeanProperty
|
||||
|
||||
import scala.jdk.CollectionConverters._
|
||||
|
||||
@@ -45,51 +46,34 @@ object Main {
|
||||
def index() = {
|
||||
val context = new Context()
|
||||
|
||||
import scala.beans.BeanProperty
|
||||
final case class Testimonial(
|
||||
@BeanProperty var avatarUrl: String,
|
||||
@BeanProperty var author: String,
|
||||
@BeanProperty var header: String,
|
||||
@BeanProperty var text: String,
|
||||
@BeanProperty var age: Int
|
||||
@BeanProperty var age: Int,
|
||||
@BeanProperty var additionalClasses: String
|
||||
)
|
||||
|
||||
class CompatTestimonial {
|
||||
@BeanProperty var author: String = _
|
||||
@BeanProperty var text: String = _
|
||||
@BeanProperty var age: Int = _
|
||||
|
||||
// Auxiliary constructor
|
||||
def this(author: String, text: String, age: Int) = {
|
||||
this() // Call to the primary constructor
|
||||
this.author = author
|
||||
this.text = text
|
||||
this.age = age
|
||||
}
|
||||
}
|
||||
val yo = new CompatTestimonial("Leopold", "Miawu", 188)
|
||||
// val yo = Testimonial("Leopold", "Miawu", 188)
|
||||
|
||||
// let's experiment. ugh
|
||||
class Person(
|
||||
@BeanProperty var firstName: String,
|
||||
@BeanProperty var lastName: String,
|
||||
@BeanProperty var age: Int
|
||||
) {
|
||||
override def toString: String =
|
||||
return String.format("%s, %s, %d", firstName, lastName, age)
|
||||
}
|
||||
val p = new Person("Efim", "Nefedov", 31)
|
||||
println(p)
|
||||
// println(p.getFirstName)
|
||||
|
||||
val ugh = new JTestimonial("Hell", "lala", 1234)
|
||||
|
||||
context.setVariable("justString", "oh why oh why")
|
||||
context.setVariable("oneTestimonial", ugh)
|
||||
context.setVariable(
|
||||
"testimonials",
|
||||
List(
|
||||
new JTestimonial("Leopold", "Miawu", 91),
|
||||
new JTestimonial("Aragorn", "And my sword!", 55)
|
||||
new Testimonial(
|
||||
"public/images/image-patrick.jpg",
|
||||
"Leopold",
|
||||
" Odio facilisis mauris sit amet massa vitae tortor condimentum lacinia quis vel eros donec ac odio tempor orci dapibus ultrices. ",
|
||||
" Nibh sed pulvinar proin gravida hendrerit? Massa tincidunt nunc pulvinar sapien et ligula ullamcorper malesuada proin libero nunc, consequat interdum varius sit amet, mattis vulputate enim nulla aliquet porttitor lacus! ",
|
||||
91,
|
||||
"!bg-red-500"
|
||||
),
|
||||
new Testimonial(
|
||||
"public/images/image-jonathan.jpg",
|
||||
"Aragorn",
|
||||
" Eleifend donec pretium vulputate sapien nec sagittis aliquam malesuada bibendum! ",
|
||||
" Egestas fringilla phasellus faucibus scelerisque eleifend! Dignissim enim, sit amet venenatis urna cursus eget nunc scelerisque viverra mauris, in aliquam sem fringilla ut morbi tincidunt augue interdum velit euismod in! ",
|
||||
55,
|
||||
"!bg-blue-500"
|
||||
)
|
||||
).asJava
|
||||
)
|
||||
val result = templateEngine.process("index", context)
|
||||
|
||||
Reference in New Issue
Block a user