emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] #+call split into multiple lines?


From: Achim Gratz
Subject: Re: [O] #+call split into multiple lines?
Date: Fri, 29 Mar 2013 10:25:17 +0100
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130307 Thunderbird/17.0.4

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 via email to

[Prev in Thread] Current Thread [Next in Thread]