TBS tiny but strong: how to recursively fill in data

73 views Asked by At

I use openTBS to parse an invoice template. The invoice address is supplied via a custom function. I would like to conditionally more information to the filled in data.

I was thinking of permitting the invoice address (the filled in data) to contain another TBS field, e.g. for a person to speak to, and have TBS re-parse the form. In other words, can I make TBS parse a template twice if the first run supplies a new TBS field?

Example:

[abk.invoiceaddress]

--- is replaced with -->

ACME inc.
[abk.person]
Somestreet 123
Somecity 54321

--- should be replaced with -->

ACME inc.
Mr. Knowitall
Somestreet 123
Somecity 54321

There seems to be no option for recursive replacement and calling MergeField() twice does not have the desired effect.

1

There are 1 answers

2
Skrol29 On BEST ANSWER

By default, TBS prevents from TBS fields injection when merging data. Otherwise it could be a security issue.

By default, if the data is:

ACME inc. [abk.person] Somestreet 123 Somecity 54321

then it will be merged as:

ACME inc. &#91abk.person] Somestreet 123 Somecity 54321

The string &#91 is the unicode for [, so this is not visible for lot of templates.

But you can lift this protection using parameter protect=no

See https://www.tinybutstrong.com/manual.php#html_field_prm_protect