test.org: Use verbatim LaTeX fragments. Added noexport for WIP items.
[org-mode/org-jambu.git] / lisp / ob-sass.el
blob8a3b5fde8fd1d3feb6dc0253d4343ea6d5b3f12a
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
8 ;; Version: 7.5
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/>.
25 ;;; Commentary:
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.
37 ;;; Requirements:
39 ;; - sass-mode :: http://github.com/nex3/haml/blob/master/extra/sass-mode.el
41 ;;; Code:
42 (require 'ob)
43 (require 'ob-eval)
45 (defvar org-babel-default-header-args:sass '())
47 (defun org-babel-execute:sass (body params)
48 "Execute a block of Sass code with Babel.
49 This function is called by `org-babel-execute-src-block'."
50 (let* ((result-params (split-string (or (cdr (assoc :results params)) "")))
51 (file (cdr (assoc :file params)))
52 (out-file (or file (org-babel-temp-file "sass-out-")))
53 (cmdline (cdr (assoc :cmdline params)))
54 (in-file (org-babel-temp-file "sass-in-"))
55 (cmd (concat "sass " (or cmdline "")
56 " " (org-babel-process-file-name in-file)
57 " " (org-babel-process-file-name out-file))))
58 (with-temp-file in-file
59 (insert (org-babel-expand-body:generic body params)))
60 (org-babel-eval cmd "")
61 (if file
62 nil ;; signal that output has already been written to file
63 (with-temp-buffer (insert-file-contents out-file) (buffer-string)))))
65 (defun org-babel-prep-session:sass (session params)
66 "Raise an error because sass does not support sessions."
67 (error "Sass does not support sessions"))
69 (provide 'ob-sass)
71 ;; arch-tag: 2954b169-eef4-45ce-a8e5-3e619f0f07ac
73 ;;; ob-sass.el ends here