1 ;;; ob-sass.el --- Babel Functions for the Sass CSS generation language -*- lexical-binding: t; -*-
3 ;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
5 ;; Author: Eric Schulte
6 ;; Keywords: literate programming, reproducible research
7 ;; Homepage: https://orgmode.org
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
26 ;; For more information on sass see http://sass-lang.com/
28 ;; This accepts a 'file' header argument which is the target of the
29 ;; compiled sass. The default output type for sass evaluation is
30 ;; either file (if a 'file' header argument was given) or scalar if no
31 ;; such header argument was supplied.
33 ;; A 'cmdline' header argument can be supplied to pass arguments to
34 ;; the sass command line.
38 ;; - sass-mode :: http://github.com/nex3/haml/blob/master/extra/sass-mode.el
43 (defvar org-babel-default-header-args
:sass
'())
45 (defun org-babel-execute:sass
(body params
)
46 "Execute a block of Sass code with Babel.
47 This function is called by `org-babel-execute-src-block'."
48 (let* ((file (cdr (assq :file params
)))
49 (out-file (or file
(org-babel-temp-file "sass-out-")))
50 (cmdline (cdr (assq :cmdline params
)))
51 (in-file (org-babel-temp-file "sass-in-"))
52 (cmd (concat "sass " (or cmdline
"")
53 " " (org-babel-process-file-name in-file
)
54 " " (org-babel-process-file-name out-file
))))
55 (with-temp-file in-file
56 (insert (org-babel-expand-body:generic body params
)))
57 (org-babel-eval cmd
"")
59 nil
;; signal that output has already been written to file
60 (with-temp-buffer (insert-file-contents out-file
) (buffer-string)))))
62 (defun org-babel-prep-session:sass
(_session _params
)
63 "Raise an error because sass does not support sessions."
64 (error "Sass does not support sessions"))
70 ;;; ob-sass.el ends here