Hi Stefan,
I'm almost certain that filters hold the answer to your questions.
Especially since they include operators like subfilter[], then[] and else[]
—and also *~run* constructs. Here is an example of what you can write with
recent TW5 releases:
\define default_subject() My default subject
\define subject-filter() [[My form]get[subject]else<default_subject>]
Subject : <$text text={{{ [subfilter<subject-filter>] }}}/>
Does it sound usable for your use case?
Cheers,
-- Xavier Cazin
On Wed, Oct 30, 2019 at 10:04 AM Stephan Hradek <[email protected]>
wrote:
> Background of my question: For a colleague who often needs to write
> standard mails I've created a TiddlyWiki where one can create 2 tiddlers.
> One with the standard mailtext using place holders. The placeholders are
> also defined in the template. Example below. The other tiddler is simply
> one piping the mailtemplate-tiddler through a tiddler which will generate
> the form to fill in the placeholders.
>
> Example for the mailtemplate:
>
> [[subject:Request for offer {{!!company}}]]
> [[recipients:[email protected]]]
> [[company:Company Name]]
> [[due_date:Due date]]
> [[revenue:Annual revenue]]
> [[known_cb,not,already:Company known]]
>
> Dear Mr. Offerman
>
> The company {{!!company}} asked for an offer.
>
> Their annual revenue is {{!!revenue}}.
>
> The due date is {{!!due_date]].
>
> {{!!company}} is {{known_cb}} known to us.
>
> Best regards…
>
> The tiddler showing the form is then just something like this:
>
> {{
> Mailtemplate:Request for offer -- Generate Mail
> ||
> Create Mail
> }}
>
> and the resulting form will look something like this:
>
> +----------------+---------------------------------+
> | Recipients | [email protected] |
> +----------------+---------------------------------+
> | Subject | Request for offer {{!!company}} |
> +----------------+---------------------------------+
> | Company | [_____________] |
> +----------------+---------------------------------+
> | Due date | [_____________] [cal] |
> +----------------+---------------------------------+
> | Annual revenue | [_____________] |
> +----------------+---------------------------------+
> |Company known | [_] already |
> +----------------+---------------------------------+
>
>
> This already works quite well, but I do not really like the notation of
> the placeholders {{!!placeholder}}. This is due to the fact that the
> generated form simply stores the values in fields in the mailtemplate.
>
> Since I had difficulties with the recipients and the subject, they are not
> editable and are not in fields. I first wanted to make them editable but
> this did not work as the defaults won't appear unless the tiddler, where
> the fields are located, does not exist. Moreover the defaults are not
> stored unless you explicitly go into the fields. As a result these 2 values
> are stored in variables.
>
> So my next idea was: Wouldn't it be nice, placeholders could be written in
> the form <<placeholder>>?
>
> Unfortunately I am not able to generate a set of variables dynamically.
> You see: I do not know beforehand which placeholders will be used in a
> mailtemplate. So I go through the mailtemplate with the ListWidget, finding
> the placeholders from the top part, generating the input elements. Creating
> variables by this is of course not possible.
>
> But maybe someone here has an idea how to do this?
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "TiddlyWiki" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/tiddlywiki/f472935c-703f-40ff-b8fc-dbfffd3148a6%40googlegroups.com
> <https://groups.google.com/d/msgid/tiddlywiki/f472935c-703f-40ff-b8fc-dbfffd3148a6%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/CADeSwYNmnAANLb7F%3DHm%3DYmJ98JPy9LxW7wK%3DeDWgQ9wL8PB5uw%40mail.gmail.com.