Update to Org mode 7.4
[bpt/emacs.git] / lisp / org / ob-sass.el
CommitLineData
86fbb8ca
CD
1;;; ob-sass.el --- org-babel functions for the sass css generation language
2
3;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
4
5;; Author: Eric Schulte
6;; Keywords: literate programming, reproducible research
7;; Homepage: http://orgmode.org
acedf35c 8;; Version: 7.4
86fbb8ca
CD
9
10;; This file is part of GNU Emacs.
11
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.
16
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.
21
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/>.
24
25;;; Commentary:
26
27;; For more information on sass see http://sass-lang.com/
28;;
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.
33;;
34;; A 'cmdline' header argument can be supplied to pass arguments to
35;; the sass command line.
36
37;;; Requirements:
38
39;; - sass-mode :: http://github.com/nex3/haml/blob/master/extra/sass-mode.el
40
41;;; Code:
42(require 'ob)
43
44(defvar org-babel-default-header-args:sass '())
45
86fbb8ca
CD
46(defun org-babel-execute:sass (body params)
47 "Execute a block of Sass code with Babel.
48This function is called by `org-babel-execute-src-block'."
49 (let* ((result-params (split-string (or (cdr (assoc :results params)) "")))
50 (file (cdr (assoc :file params)))
afe98dfa 51 (out-file (or file (org-babel-temp-file "sass-out-")))
86fbb8ca 52 (cmdline (cdr (assoc :cmdline params)))
afe98dfa
CD
53 (in-file (org-babel-temp-file "sass-in-"))
54 (cmd (concat "sass " (or cmdline "")
55 " " (org-babel-process-file-name in-file)
56 " " (org-babel-process-file-name out-file))))
86fbb8ca 57 (with-temp-file in-file
afe98dfa 58 (insert (org-babel-expand-body:generic body params))) (shell-command cmd)
86fbb8ca
CD
59 (or file (with-temp-buffer (insert-file-contents out-file) (buffer-string)))))
60
61(defun org-babel-prep-session:sass (session params)
62 "Raise an error because sass does not support sessions."
63 (error "Sass does not support sessions"))
64
65(provide 'ob-sass)
66
67;; arch-tag: 2954b169-eef4-45ce-a8e5-3e619f0f07ac
68
69;;; ob-sass.el ends here