From 66013ae1c60ed15a7f203c38de14613e101cf4c0 Mon Sep 17 00:00:00 2001 From: efim Date: Sat, 1 Jul 2023 14:20:52 +0000 Subject: [PATCH] feat(14): template in showdown-table, show choice --- .../src/main/resources/templates/index.html | 2 +- .../main/resources/templates/showdown.html | 3 +++ .../main/scala/rockpaperscissors/Main.scala | 23 +++++++++++++++---- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/14-rock-paper-scissors/src/main/resources/templates/index.html b/14-rock-paper-scissors/src/main/resources/templates/index.html index f00069c..aefb2fc 100644 --- a/14-rock-paper-scissors/src/main/resources/templates/index.html +++ b/14-rock-paper-scissors/src/main/resources/templates/index.html @@ -74,8 +74,8 @@
+ +
"text/html;charset=UTF-8") - ) + val badge = Models.choiceSelectionItems.find(_.c.name == choice) + val response = badge match { + case Some(playersChoiceBadge) => + val badge = playersChoiceBadge.copy() + badge.p = Positioning.Relative + context.setVariable("playersChoiceData", badge) + val result = templateEngine.process("showdown", Set("showdown-table").asJava, context) + cask.Response( + result, + headers = Seq("Content-Type" -> "text/html;charset=UTF-8") + ) + case None => + cask.Response(s"Unknown choice: '${choice}'", 400) + } + response } @cask.staticResources("/public")