gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] branch master updated: Serving a first / test Jinja page


From: gnunet
Subject: [libeufin] branch master updated: Serving a first / test Jinja page
Date: Mon, 21 Jun 2021 12:32:36 +0200

This is an automated email from the git hooks/post-receive script.

ms pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new aac6465  Serving a first / test Jinja page
aac6465 is described below

commit aac64654698340f547ae847a72c716ae7a0a3f64
Author: ms <ms@taler.net>
AuthorDate: Mon Jun 21 12:32:27 2021 +0200

    Serving a first / test Jinja page
---
 sandbox/build.gradle                                  |  1 +
 sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt | 19 +++++++++++++++++++
 sandbox/src/main/resources/templates/hello.html       |  1 +
 3 files changed, 21 insertions(+)

diff --git a/sandbox/build.gradle b/sandbox/build.gradle
index b7ab223..ce04568 100644
--- a/sandbox/build.gradle
+++ b/sandbox/build.gradle
@@ -44,6 +44,7 @@ def ktor_version = "1.5.0"
 def exposed_version = "0.25.1"
 
 dependencies {
+    implementation "com.hubspot.jinjava:jinjava:2.5.9"
     implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
     implementation "ch.qos.logback:logback-classic:1.2.3"
     implementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1'
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index efea041..25ef80f 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -20,6 +20,8 @@
 
 package tech.libeufin.sandbox
 
+import com.hubspot.jinjava.Jinjava
+import com.hubspot.jinjava.JinjavaConfig
 import com.fasterxml.jackson.core.JsonParseException
 import io.ktor.application.ApplicationCallPipeline
 import io.ktor.application.call
@@ -63,6 +65,8 @@ import com.github.ajalt.clikt.parameters.options.default
 import com.github.ajalt.clikt.parameters.options.option
 import com.github.ajalt.clikt.parameters.options.versionOption
 import com.github.ajalt.clikt.parameters.types.int
+import com.google.common.collect.Maps
+import com.google.common.io.Resources
 import execThrowableOrTerminate
 import io.ktor.application.ApplicationCall
 import io.ktor.http.*
@@ -87,6 +91,7 @@ import tech.libeufin.util.ebics_h004.EbicsTypes
 import java.net.BindException
 import java.util.*
 import kotlin.random.Random
+import kotlin.reflect.jvm.internal.impl.load.kotlin.JvmType
 import kotlin.system.exitProcess
 
 val SANDBOX_DB_ENV_VAR_NAME = "LIBEUFIN_SANDBOX_DB_CONNECTION"
@@ -290,7 +295,21 @@ fun serverMain(dbName: String, port: Int) {
             }
         }
         routing {
+            get("/jinja-test") {
+                val template = Resources.toString(
+                    Resources.getResource("templates/hello.html"),
+                    Charsets.UTF_8
+                )
+                val context = mapOf("token" to "dynamic")
+                val page = Jinjava().render(template, context)
+                call.respond(page)
+                return@get
+            }
+
             static("/static") {
+                /**
+                 * Here Sandbox will serve the CSS files.
+                 */
                 resources("static")
             }
 
diff --git a/sandbox/src/main/resources/templates/hello.html 
b/sandbox/src/main/resources/templates/hello.html
new file mode 100644
index 0000000..70e073e
--- /dev/null
+++ b/sandbox/src/main/resources/templates/hello.html
@@ -0,0 +1 @@
+Hello, I'm a Jinja '{{ token }}' page!
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]