org-babel-asymptote now supports interactive viewing if the :file header argument...
[org-mode.git] / contrib / babel / lisp / langs / org-babel-sass.el
blobd20e91da863571ca60cd187143493bd903544a2e
1 ;;; org-babel-sass.el --- org-babel functions for the sass css generation language
3 ;; Copyright (C) 2009 Eric Schulte
5 ;; Author: Eric Schulte
6 ;; Keywords: literate programming, reproducible research
7 ;; Homepage: http://orgmode.org
8 ;; Version: 0.01
10 ;;; License:
12 ;; This program 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, or (at your option)
15 ;; any later version.
17 ;; This program 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; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 ;; Boston, MA 02110-1301, USA.
27 ;;; Commentary:
29 ;; For more information on sass see http://sass-lang.com/
31 ;; This accepts a 'file' header argument which is the target of the
32 ;; compiled sass. The default output type for sass evaluation is
33 ;; either file (if a 'file' header argument was given) or scalar if no
34 ;; such header argument was supplied.
36 ;; A 'cmdline' header argument can be supplied to pass arguments to
37 ;; the sass command line.
39 ;;; Requirements:
41 ;; - sass-mode :: http://github.com/nex3/haml/blob/master/extra/sass-mode.el
43 ;;; Code:
44 (require 'org-babel)
45 (require 'sass-mode)
47 (org-babel-add-interpreter "sass")
49 (add-to-list 'org-babel-tangle-langs '("sass" "sass"))
51 (defun org-babel-execute:sass (body params)
52 "Execute a block of Sass code with org-babel. This function is
53 called by `org-babel-execute-src-block'."
54 (message "executing Sass source code block")
55 (let* ((result-params (split-string (or (cdr (assoc :results params)) "")))
56 (file (cdr (assoc :file params)))
57 (out-file (or file (make-temp-file "org-babel-sass-out")))
58 (cmdline (cdr (assoc :cmdline params)))
59 (in-file (make-temp-file "org-babel-sass-in"))
60 (cmd (concat "sass " (or cmdline "") in-file " " out-file)))
61 (with-temp-file in-file (insert body)) (shell-command cmd)
62 (or file (with-temp-buffer (insert-file-contents out-file) (buffer-string)))))
64 (defun org-babel-prep-session:sass (session params)
65 (error "Sass does not support sessions"))
67 (provide 'org-babel-sass)
68 ;;; org-babel-sass.el ends here