1 ;;; ob-sass.el --- org-babel functions for the sass css generation language
3 ;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
5 ;; Author: Eric Schulte
6 ;; Keywords: literate programming, reproducible research
7 ;; Homepage: http://orgmode.org
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
27 ;; For more information on sass see http://sass-lang.com/
29 ;; This accepts a 'file' header argument which is the target of the
30 ;; compiled sass. The default output type for sass evaluation is
31 ;; either file (if a 'file' header argument was given) or scalar if no
32 ;; such header argument was supplied.
34 ;; A 'cmdline' header argument can be supplied to pass arguments to
35 ;; the sass command line.
39 ;; - sass-mode :: http://github.com/nex3/haml/blob/master/extra/sass-mode.el
44 (defvar org-babel-default-header-args
:sass
'())
46 (defun org-babel-expand-body:sass
(body params
&optional processed-params
)
47 "Expand BODY according to PARAMS, return the expanded body." body
)
49 (defun org-babel-execute:sass
(body params
)
50 "Execute a block of Sass code with Babel.
51 This function is called by `org-babel-execute-src-block'."
52 (let* ((result-params (split-string (or (cdr (assoc :results params
)) "")))
53 (file (cdr (assoc :file params
)))
54 (out-file (or file
(make-temp-file "org-babel-sass-out")))
55 (cmdline (cdr (assoc :cmdline params
)))
56 (in-file (make-temp-file "org-babel-sass-in"))
57 (cmd (concat "sass " (or cmdline
"") in-file
" " out-file
)))
58 (with-temp-file in-file
59 (insert (org-babel-expand-body:sass body params
))) (shell-command cmd
)
60 (or file
(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"))
68 ;; arch-tag: 2954b169-eef4-45ce-a8e5-3e619f0f07ac
70 ;;; ob-sass.el ends here