ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Wolfgang Schuster <wolfgang.schuster.lists@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>,
	Henning Hraban Ramm <texml@fiee.net>
Subject: Re: serial letters
Date: Tue, 9 Apr 2019 21:38:01 +0200	[thread overview]
Message-ID: <e746be5d-da69-6cc6-3bd4-7da7db74dff1@gmail.com> (raw)
In-Reply-To: <7525A011-3996-4BEA-8AD2-F7AED5AD3317@fiee.net>

Henning Hraban Ramm schrieb am 08.04.2019 um 15:26:
> How would you approach serial letters, e.g. to all members of a club?
> (Actually I need to send out donation receipts.)
>
> I’d like to use the letter module, since my usual letter design is using it.
>
> I can export the addresses to CSV, JSON, Lua tables or whatever or transfer them to a SQLite db.
> Would it make more sense to read them in Lua and combine this data with a buffer, or to write a single tex file for every letter?
> I know how to do the latter, but I’d like to learn a more ConTeXt-ish way.
> Would it make sense to use the bibliographies module?

You can use the letter module when you drop the normal 
letter-environment which is to limited in this case because it uses the 
buffer mechanism to store the content.

To have more control over the content for the opening etc. you can 
switch to the setups alternative (even the content can be set in this 
way instead of the default buffer) and set all texts with a setups-block.

The letter itself can be flushed with the \placeletter command, below is 
a simple example where I flush the letter after each variables setting 
but you should be able to do the same with a lua table or csv file.

\usemodule[letter]

\setuplettersection
   [opening]
   [alternative=setups]

\startsetups [letter:section:opening]
   \doifelse{\getvariable{address}{sex}}{male}
     {Dear Sir,}
     {Dear Madam,}
\stopsetups

\setvariable{address}{set}{\placeletter}

\starttext

\startlettercontent
\unknown
\stoplettercontent

\setvariables
   [address]
   [name=John,
    sex=male]

\setvariables
   [address]
   [name=Anna,
    sex=female]

\stoptext

Wolfgang

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2019-04-09 19:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-08 13:26 Henning Hraban Ramm
2019-04-09 19:38 ` Wolfgang Schuster [this message]
2019-04-10  7:08   ` Henning Hraban Ramm
2019-05-06 11:15     ` Jan U. Hasecke
2019-05-07 10:08       ` Henning Hraban Ramm
2019-05-24 11:49 ` Jean-Philippe Rey
2019-05-24 16:05   ` Wolfgang Schuster
2019-05-24 18:19     ` jean-philippe.rey

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

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

  git send-email \
    --in-reply-to=e746be5d-da69-6cc6-3bd4-7da7db74dff1@gmail.com \
    --to=wolfgang.schuster.lists@gmail.com \
    --cc=ntg-context@ntg.nl \
    --cc=texml@fiee.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.
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 NNTP newsgroup(s).