summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2011-06-21 12:18:58 +0200
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2011-06-21 12:18:58 +0200
commit950c88fb85dcb83102610efd401c7761c30cddf6 (patch)
tree237c083d62c6d1b38ba9f7eac06611dae1e8f545
parent4e206241aeaee801de8e1d0b86048ecc462b27eb (diff)
Wrap templates in a struct type.
-rwxr-xr-x[-rw-r--r--]json-template.rkt10
1 files changed, 7 insertions, 3 deletions
diff --git a/json-template.rkt b/json-template.rkt
index 384f31f..b32b4ab 100644..100755
--- a/json-template.rkt
+++ b/json-template.rkt
@@ -179,11 +179,14 @@
(let-values ([(stuff reason rest) (parse-structure x)])
stuff))
+(struct template (expander)
+ #:property prop:procedure (struct-field-index expander))
+
(define (read-template #:meta-left [meta-left "{"]
#:meta-right [meta-right "}"]
#:default-formatter [default-formatter "raw"]
#:format-char [format-char "|"])
- (let ([template
+ (let ([template-data
(parse-structure*
(remove-spurious-newlines-from-token-groups
(parse-token-groups
@@ -192,8 +195,9 @@
meta-left
meta-right
format-char))))])
- (λ (context)
- (expand-template template (list context) default-formatter))))
+ (template
+ (λ (context)
+ (expand-template template-data (list context) default-formatter)))))
(define (name->path bytename)
(let ([name (bytes->string/utf-8 bytename)])