~bakpakin/temple

ref: e7d6a355857991a00525a237928a466a781d94f5 temple/test/basic.janet -rw-r--r-- 603 bytes
e7d6a355Calvin Rose First commit. 1 year, 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
(import ../temple :as temple)
(temple/add-loader)

(defn check-template
  [template args expected]
  (def buf @"")
  (with-dyns [:out buf]
    (template args)
    (def sbuf (string/trim (string buf)))
    (if (= sbuf expected)
      (eprint "pass")
      (do
        (eprint)
        (eprint "fail - expected " (describe expected)
               ", got " (describe sbuf))
        (eprint)))))

(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>
```)