crater icon indicating copy to clipboard operation
crater copied to clipboard

Templating fields only if set

Open patricklucas opened this issue 2 years ago • 0 comments

Perhaps this is already supported, but I wasn't able to figure it out.

I have added an optional custom field for invoices "Customer Reference", which I would like to include beneath the customer address only if a value has been provided.

Currently, on invoices without a customer reference, "Reference:" with no value appears below the customer's address.

My workaround right now is to always tweak the global customer address format prior to downloading and manually sending invoice PDFs, depending on whether or not a reference is set, which is obviously not ideal.

A solution would be to have either a formatting/richer templating syntax ({if CUSTOM_FIELD}{CUSTOM_FIELD}{endif} or somesuch) or to add custom formatting to the fields themselves. For example, when defining a field, optionally specifying a template string that gets rendered first, e.g. Reference: {value}, which gets rendered all-or-nothing when the field is referenced elsewhere.

patricklucas avatar Jul 02 '22 11:07 patricklucas