Use Slashdot.org as feed example in the documentation
[org-mode/org-jambu.git] / lisp / ob-sass.el
blobe762d3d3381daa76a9f590c4bb20feb2b031f2ad
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: 0.01
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)
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 org-babel. This function is
51 called by `org-babel-execute-src-block'."
52 (message "executing Sass source code block")
53 (let* ((result-params (split-string (or (cdr (assoc :results params)) "")))
54 (file (cdr (assoc :file params)))
55 (out-file (or file (make-temp-file "org-babel-sass-out")))
56 (cmdline (cdr (assoc :cmdline params)))
57 (in-file (make-temp-file "org-babel-sass-in"))
58 (cmd (concat "sass " (or cmdline "") in-file " " out-file)))
59 (with-temp-file in-file
60 (insert (org-babel-expand-body:sass body params))) (shell-command cmd)
61 (or file (with-temp-buffer (insert-file-contents out-file) (buffer-string)))))
63 (defun org-babel-prep-session:sass (session params)
64 "This function does nothing as sass does not support sessions."
65 (error "Sass does not support sessions"))
67 (provide 'ob-sass)
69 ;; arch-tag: 2954b169-eef4-45ce-a8e5-3e619f0f07ac
71 ;;; ob-sass.el ends here