Commit 0931134c3f2145ec1068f0192ac404e15d7a7ee5

Thomas de Grivel 2013-12-21T20:22:20

Use NIL value for unbound variables in compiled templates.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
diff --git a/template.lisp b/template.lisp
index c8de3fe..f7865f6 100644
--- a/template.lisp
+++ b/template.lisp
@@ -134,8 +134,11 @@
 (defun compile-template (template)
   (let ((vars (collect-vars template)))
     (compile nil `(lambda ()
-		    (declare (special ,@vars))
-		    ,@template))))
+		    (symbol-macrolet ,(mapcar (lambda (v)
+						`(,v (when (boundp ',v)
+						       (symbol-value ',v))))
+					      vars)
+		      ,@template)))))
 
 ;;  File-level cache