aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorJosef Pospíšil <josef.pospisil@laststar.eu>2021-01-21 18:37:28 +0100
committerJosef Pospíšil <josef.pospisil@laststar.eu>2021-01-21 18:37:28 +0100
commit2ccb21ee1669a64e7b18d972f9f72111f8f778c4 (patch)
tree211c4dcec81b86c3d5e8092075bbd3f69f6173b4 /test
parentMerge pull request #15 from pepe/add-test (diff)
Add temple
Diffstat (limited to 'test')
-rw-r--r--test/suite8.janet33
-rw-r--r--test/templates/hi.temple4
-rw-r--r--test/templates/hop.temple2
3 files changed, 39 insertions, 0 deletions
diff --git a/test/suite8.janet b/test/suite8.janet
new file mode 100644
index 0000000..bd1078f
--- /dev/null
+++ b/test/suite8.janet
@@ -0,0 +1,33 @@
+(import ../spork/temple :as temple)
+(import spork/test)
+
+(temple/add-loader)
+
+(test/start-suite 8)
+
+(defn check-template
+ [template args expected]
+ (def buf @"")
+ (with-dyns [:out buf]
+ (template args)
+ (def sbuf (string/trim (string buf)))
+ (test/assert (= sbuf expected) (string "Render of " template))))
+
+(import ./templates/hi :as hi)
+(import ./templates/hop :as hop)
+
+(check-template hi/render-dict {:a 1 :b 2}
+ ```
+ <html>
+ 6
+ </html>
+ ```)
+
+(check-template hop/render-dict {:a 1 :b 2}
+ ```
+ <html>
+ 6
+ </html>
+ ```)
+
+(test/end-suite)
diff --git a/test/templates/hi.temple b/test/templates/hi.temple
new file mode 100644
index 0000000..1c32d4b
--- /dev/null
+++ b/test/templates/hi.temple
@@ -0,0 +1,4 @@
+{$ (defn myfn [x] (+ x x)) $}
+<html>
+ {{ (myfn (length (range (+ (args :a) (args :b))))) }}
+</html>
diff --git a/test/templates/hop.temple b/test/templates/hop.temple
new file mode 100644
index 0000000..4353c70
--- /dev/null
+++ b/test/templates/hop.temple
@@ -0,0 +1,2 @@
+{$ (import ./hi :as hi) $}
+{% (hi/render-dict args) %}