-
Notifications
You must be signed in to change notification settings - Fork 3
/
expansion.lisp
34 lines (25 loc) · 974 Bytes
/
expansion.lisp
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
34
;; cl-uri-templates
;; Extensive URI-Templates implementation in Common-Lisp.
;;
;; Copyright 2009 Thomas de Grivel <[email protected]>
;; Copyright (c) 2007, 2008, 2009 Vladimir Sedach
;;
;; This software is provided "AS IS".
;; Please see COPYING for details.
(in-package #:cl-uri-templates)
(defmacro expand-uri-template-var (var &optional default)
`(or (uri-var ',var)
(handler-case ,var
(unbound-variable ()
,default))))
(defmacro expand-uri-template (template)
(declare (type uri-template template))
`(macrolet ((uri-template-var (var &optional default)
`(expand-uri-template-var ,var ,default)))
,(if (stringp template)
(parse-uri-template template)
template)))
(defun uri-template (&rest template-args)
(format nil "~{~@[~A~]~}" template-args))
#+parenscript (parenscript:defpsmacro uri-template (&rest template-args)
`(+ ,@template-args))