Next: Header arguments in function calls, Previous: Language-specific header arguments in Org mode properties, Up: Using header arguments [Contents][Index]
The most common way to assign values to header arguments is at the
code block level. This can be done by listing a sequence of header
arguments and their values as part of the #+BEGIN_SRC
line.
Properties set in this way override both the values of
org-babel-default-header-args
and header arguments specified as
properties. In the following example, the :results
header argument
is set to silent
, meaning the results of execution will not be
inserted in the buffer, and the :exports
header argument is set to
code
, meaning only the body of the code block will be
preserved on export to HTML or LaTeX.
#+NAME: factorial #+BEGIN_SRC haskell :results silent :exports code :var n=0 fac 0 = 1 fac n = n * fac (n-1) #+END_SRC
Similarly, it is possible to set header arguments for inline code blocks
src_haskell[:exports both]{fac 5}
Code block header arguments can span multiple lines using #+HEADER:
or
#+HEADERS:
lines preceding a code block or nested between the
#+NAME:
line and the #+BEGIN_SRC
line of a named code block.
Multi-line header arguments on an un-named code block:
#+HEADERS: :var data1=1 #+BEGIN_SRC emacs-lisp :var data2=2 (message "data1:%S, data2:%S" data1 data2) #+END_SRC #+RESULTS: : data1:1, data2:2
Multi-line header arguments on a named code block:
#+NAME: named-block #+HEADER: :var data=2 #+BEGIN_SRC emacs-lisp (message "data:%S" data) #+END_SRC #+RESULTS: named-block : data:2