emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Achim Gratz <Stromeko@Nexgo.DE>
To: emacs-orgmode@gnu.org
Subject: Re: #+call split into multiple lines?
Date: Fri, 29 Mar 2013 10:25:17 +0100	[thread overview]
Message-ID: <kj3mjq$sgm$1@ger.gmane.org> (raw)
In-Reply-To: <3741EDEB-8A94-4402-85D3-D74236811F97@nf.mpg.de>

Am 29.03.2013 09:24, schrieb Stefan Vollmar:
[...]
> This might work reasonably well - if
> (1) I could prevent the table from being exported to HTML,
> (2) (probably more difficult) if this kind of thing would work:
>
> #+call: hcard(v=card-table) :results html

It does, see:
http://orgmode.org/manual/Evaluating-code-blocks.html#Evaluating-code-blocks

----->8-----
* Data								   :noexport:
#+name: card-table
| cname | Dr. Stefan Vollmar |
| gname | Stefan             |
| photo | stefan-vollmar.jpg |

#+name: get_named_table_row
#+header: :var key="cname"
#+header: :var table=card-table
#+begin_src emacs-lisp
(cadr (assoc key table))
#+end_src

#+name: mhead-hcard
#+header: :var cname=get_named_table_row(key="cname")
#+header: :var gname=get_named_table_row(key="gname")
#+header: :var photo=get_named_table_row(key="photo")
#+header: :var prefix=""
#+header: :var web="web-page.html"
#+begin_src org :exports none
<div id="contact" class="vcard">
   <p>
     <table style="margin-left:0;margin-right:auto">
       <tr style="text-align: left;margin-left: 2em">
         <td style="padding: 5px">
           <img width="200px" class="photo" src="images/$photo" 
alt="$cname" />
         </td>
         <td><a style="color:blue;" class="url" 
href="http://www.nf.mpg.de/cv/$web">
           <div class="fn n">
             <span class="honorific-prefix">$prefix</span>
             <span class="given-name">$gname</span>
...
#+end_src


* VCard

#+call: mhead-hcard()

#+RESULTS: mhead-hcard()
#+begin_example
<div id="contact" class="vcard">
   <p>
     <table style="margin-left:0;margin-right:auto">
       <tr style="text-align: left;margin-left: 2em">
         <td style="padding: 5px">
           <img width="200px" class="photo" 
src="images/stefan-vollmar.jpg" alt="Dr. Stefan Vollmar" />
         </td>
         <td><a style="color:blue;" class="url" 
href="http://www.nf.mpg.de/cv/web-page.html">
           <div class="fn n">
             <span class="honorific-prefix"></span>
             <span class="given-name">Stefan</span>
...
#+end_example
-----8<-----

> My feeling is (please correct me if I am wrong) that maybe we would
> want two Babel blocks: one for setting a set of variables/an array
> (elisp?) and one for filling the template?

Possibly.  You might also want to consider noweb syntax or named results.

> Could I fill a suitable structure/array/set of variables within an
> elisp block and then reference it/them in the org template that only
> requires replacing placeholders?

You already get the table as a list of lists structure when referenced 
as a variable in the call, see above.  The variable indexing might 
reasonably be extended to extract named rows and columns so that the 
helper function would not be needed and something like 
cname=card-table["cname",] would be possible, I'd think.


Regards,
-- 
Achim.

(on the road :-)

  reply	other threads:[~2013-03-29  9:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-28 20:49 #+call split into multiple lines? Stefan Vollmar
2013-03-28 21:17 ` Thomas S. Dye
2013-03-28 21:27   ` Sebastien Vauban
2013-03-28 21:51     ` Thomas S. Dye
2013-03-29  8:24       ` Stefan Vollmar
2013-03-29  9:25         ` Achim Gratz [this message]
2013-03-29  9:34         ` feng shu
2013-03-29  2:33     ` Eric Abrahamsen
2013-03-29  2:43       ` Thomas S. Dye
2013-03-29  3:14         ` Eric Abrahamsen
2013-03-29  7:18 ` Achim Gratz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='kj3mjq$sgm$1@ger.gmane.org' \
    --to=stromeko@nexgo.de \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).