feat(13): rest route get single testimonial card
not ideal, that i need separate file, even though i can use the fragment from the main file. and having th:eac in same place as th:fragment means rendering that fragment and passing element over which i'm iterating doesn't help if collection is empty
This commit is contained in:
parent
c9195759a8
commit
3e00aa5f3d
|
@ -34,6 +34,7 @@
|
|||
<body class="grid place-content-center bg-light-grayish-blue grid-flow-dense">
|
||||
<div class="py-20 px-7 space-y-7 min-h-screen text-white md:grid md:gap-[30px] md:py-0 md:px-0 h-max max-w-[1200px] md:grid-cols-[repeat(auto-fill,_255px)] md:auto-rows-[280px] md:mt-[160px] md:space-y-0">
|
||||
<section
|
||||
th:fragment="testimonialSection(testimonials)"
|
||||
th:each="testimonial : ${testimonials}"
|
||||
th:classappend="${testimonial.additionalClasses}? ${testimonial.additionalClasses} : 'bg-moderate-violet md:col-span-2'"
|
||||
class="py-7 px-10 flex flex-col justify-between rounded-xl first:bg-[url('../public/images/bg-pattern-quotation.svg')] bg-no-repeat bg-[right_2rem_top] drop-shadow "
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
<section
|
||||
th:replace="index::testimonialSection(testimonials=${selectedTestimonials})">
|
||||
</section>
|
|
@ -54,6 +54,22 @@ object Main {
|
|||
headers = Seq("Content-Type" -> "text/html;charset=UTF-8")
|
||||
)
|
||||
}
|
||||
@cask.get("/testimonial/:id")
|
||||
def getTestimonial(id: Int) = {
|
||||
val context = new Context()
|
||||
val test = Testimonial.sameAsRequested.head
|
||||
context.setVariable(
|
||||
"selectedTestimonials",
|
||||
List(test).asJava
|
||||
)
|
||||
val result = templateEngine.process("testimonialSection", context)
|
||||
println(s"will try with $test ; to get \n$result")
|
||||
cask.Response(
|
||||
result,
|
||||
headers = Seq("Content-Type" -> "text/html;charset=UTF-8")
|
||||
)
|
||||
}
|
||||
|
||||
@cask.staticFiles("/dist")
|
||||
def distFiles() = "dist"
|
||||
@cask.staticFiles("/public")
|
||||
|
|
Loading…
Reference in New Issue