emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Max Nikulin <manikulin@gmail.com>
To: "Juan Manuel Macías" <maciaschain@posteo.net>,
	orgmode <emacs-orgmode@gnu.org>
Subject: Re: [proof of concept, tip] 'Templates with arguments' using org src blocks
Date: Fri, 13 Oct 2023 23:00:13 +0700	[thread overview]
Message-ID: <243f586a-f150-481c-8eec-17ffcacaf993@gmail.com> (raw)
In-Reply-To: <87bkdc5g2t.fsf@posteo.net>

On 06/10/2023 15:07, Juan Manuel Macías wrote:
> And, finally:
> 
> ┌────
> │ #+header: :var table = table1
> │ #+header: :var notes = "\\item [1] First note\n\\item [2] Second note"
> │ {{{template(tptable,table notes)}}}
> └────

Usage is quite close to "#+call:", but it does not support specifying 
arguments using "#+header:"
https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-org.html

I would still consider noweb (table1 is omitted):

--- 8< ---
#+property: header-args:org :exports results :results replace :noweb yes

#+NAME: tptable
#+begin_src org :exports none
   ,#+begin_table
   ,#+ATTR_LaTeX: :options [b]
   ,#+begin_threeparttable
   $table
   ,#+begin_tablenotes
   $notes
   ,#+end_tablenotes
   ,#+end_threeparttable
   ,#+end_table
#+end_src

#+header: :var table = table1
#+header: :var notes = "\\item [1] First note\n\\item [2] Second note"
#+begin_src org
   <<tptable>>
#+end_src
--- >8 ---

or "%(param)s" substitutions in python (another variant f"""{param}""" 
is inconvenient for LaTeX):

--- 8< ---
#+property: header-args:python :python python3 :results org :noweb yes 
:exports results
#+property: header-args:org :exports results :results replace
#+NAME: tptable
#+begin_src python :exports none
   return """\
   ,#+begin_table
   ,#+ATTR_LaTeX: :options [b]
   ,#+begin_threeparttable
   %(table)s
   ,#+begin_tablenotes
   %(notes)s
   ,#+end_tablenotes
   ,#+end_threeparttable
   ,#+end_table
   """ % locals()
#+end_src

#+header: :var table = table1
#+header: :var notes = "\\item [1] First note\n\\item [2] Second note"
#+begin_src python
   <<tptable>>
#+end_src
--- >8 ---


      reply	other threads:[~2023-10-13 16:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-06  8:07 [proof of concept, tip] 'Templates with arguments' using org src blocks Juan Manuel Macías
2023-10-13 16:00 ` Max Nikulin [this message]

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=243f586a-f150-481c-8eec-17ffcacaf993@gmail.com \
    --to=manikulin@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=maciaschain@posteo.net \
    /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).