From mboxrd@z Thu Jan 1 00:00:00 1970 From: Grant Rettke Subject: Re: babel header argument :var is not expanded when tangling Date: Sun, 24 Dec 2017 09:40:39 -0600 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35833) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eT8OJ-0000Li-Rf for emacs-orgmode@gnu.org; Sun, 24 Dec 2017 10:40:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eT8OI-0006as-UH for emacs-orgmode@gnu.org; Sun, 24 Dec 2017 10:40:43 -0500 Received: from mail-lf0-x22c.google.com ([2a00:1450:4010:c07::22c]:45614) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eT8OI-0006ZX-NB for emacs-orgmode@gnu.org; Sun, 24 Dec 2017 10:40:42 -0500 Received: by mail-lf0-x22c.google.com with SMTP id f13so35998683lff.12 for ; Sun, 24 Dec 2017 07:40:42 -0800 (PST) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: "numbchild@gmail.com" Cc: Org-mode > Here is a quick test: > > * Test tangle will auto expand and substitute :var > > #+begin_src js :tangle kk.js > console.log("hello, world!"); > #+end_src > > #+begin_src js :var name=3D"chris" :tangle require-kk.js > // require("kk.js"); > console.log("Hi, ", name); > #+end_src > > #+RESULTS: > : Hi, chris > > #+NAME: check whether tangle expand and substitute :var > #+begin_src shell > cat require-kk.js > #+end_src > > #+RESULTS: check whether tangle expand and substitute :var > : var name=3D"chris"; > : console.log("Hi, ", name); > > The upper result should be: ~console.log("Hi, ", "chris");~. Here are your two source blocks. They each do literate programming, one with Variable style and the other with Noweb style. When you evaluate them you get an identical result. When you tangle them you get two different pieces of code, that generate the same result. You can peek at what the tangled code will look like by calling org-babel-expand-src-block inside the source block. That is how it will look in the tangled file. I think that want Noweb style. When I use the Variable approach like this #+begin_src js :var name=3D"chris" :tangle kk.js console.log("Hi, ", name); #+end_src I get this in the tangled output file var name=3D"chris"; console.log("Hi, ", name); When I use the the Noweb approach like this #+NAME: name #+BEGIN_SRC emacs-lisp chris #+END_SRC #+NAME: org_gcr_2017-12-23_mara_3D887FDD-163D-4BE1-80E8-464BF29DABEA #+BEGIN_SRC js :tangle noweb-kk.js :comments no console.log("Hi, ", "=C2=ABname=C2=BB"); #+END_SRC I get this in the tangled output file console.log("Hi, ", "chris"); WDYT?