Debian Codegraph @

compat-api-v1.lisp

raw
1 ;;;; compat-api-v1.lisp --- APIv1 compatibility package
2
3 ;;; Copyright (C) 2014 Kan-Ru Chen (陳侃如)
4
5 ;;; Author(s): Kan-Ru Chen (陳侃如) <[email protected]>
6
7 ;;; Permission is hereby granted, free of charge, to any person obtaining a
8 ;;; copy of this software and associated documentation files (the "Software"),
9 ;;; to deal in the Software without restriction, including without limitation
10 ;;; the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 ;;; and/or sell copies of the Software, and to permit persons to whom the
12 ;;; Software is furnished to do so, subject to the following conditions:
13
14 ;;; The above copyright notice and this permission notice shall be included in
15 ;;; all copies or substantial portions of the Software.
16
17 ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 ;;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 ;;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 ;;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 ;;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 ;;; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 ;;; DEALINGS IN THE SOFTWARE.
24
25 ;;;; Code:
26
27 (in-package :mustache)
28
29 (defvar *mustache-output* (make-synonym-stream '*output-stream*)
30 "Deprecated in favor of MUSTACHE:*OUTPUT* since version 0.10.0")
31
32 (define-condition deprecation-warning (style-warning)
33 ((name :initarg :name :reader deprecated-name)
34 (replacements :initarg :replacement :reader deprecated-name-replacement)
35 (since :initarg :since :reader deprecated-since))
36 (:report (lambda (condition stream)
37 (format stream "~S is deprecated since CL-MUSTACHE version ~A. ~
38 Use ~S instead."
39 (deprecated-name condition)
40 (deprecated-since condition)
41 (deprecated-name-replacement condition)))))
42
43 (defmacro make-obsolete (obsolete-name current-name when)
44 `(defun ,obsolete-name (&rest args)
45 ,(documentation current-name 'function)
46 (warn 'deprecation-warning
47 :name ',obsolete-name :replacement ',current-name :since ,when)
48 (apply ',current-name args)))
49
50 (make-obsolete mustache-type version "0.10.0")
51 (make-obsolete mustache-version version "0.10.0")
52 (make-obsolete mustache-context make-context "0.10.0")
53 (make-obsolete mustache-compile compile-template "0.10.0")
54 (make-obsolete mustache-render render "0.10.0")
55 (make-obsolete mustache-render-to-string render* "0.10.0")
56
57 (defun mustache-render-to-stream (stream template &optional context)
58 "Render TEMPLATE with optional CONTEXT to STREAM."
59 (warn 'deprecation-warning
60 :name 'mustache-render-to-stream :replacement 'render :since "0.10.0")
61 (render template context stream))
62
63 (defmacro defmustache (name template)
64 #.(documentation 'define 'function)
65 (warn 'deprecation-warning
66 :name 'defmustache :replacement 'render :since "0.10.0")
67 `(define ,name ,template))
68
69 ;;; compat-api-v1.lisp ends here
70
71 ;;; Local Variables:
72 ;;; mode: lisp
73 ;;; End: