Templates

Helper Functions

The following helper functions are available in the template.ejs file of invoice and proposal templates.

#t

Returns a translated string for key.

t (key: string): string

#formatDate

Returns a formatted date string, respecting the language of the invoice/proposal.

formatDate (date: string): string

#formatMoneyValue

Returns a formatted money value, respecting the language of the invoice/proposal and the currency of the money value.

formatMoneyValue (value: MoneyValue): string

#join

Joins together an array of strings by a given separator, skipping falsey values.

join (strings: Array, separator: string): string

#Example

join(['Hello', '', 'World', undefined], ' • ') // "Hello • World"

#joinAddress

Joins together the components of an address by a given separator, skipping falsey values.

join (strings: Array, separator: string): string

#Example

join(invoice.seller.address, ' • ') // "Company Name • Some street 76 • 99999 Berlin • Germany"

#countryCode

Returns the name of the country, respecting the language of the invoice/proposal.

countryCode (code: string): string

#field

Returns the value of the given custom field.

field (fieldName: string): any

#clsx

The popular clsx function for generating class names.