⚡️ Ideas
Nico Baier Nico Baier Apr 20, 2023

Improved range of formatting options for title expressions

Explain the problem as you see it

Currently, there are a small number of options for formatting fields when using them in title expressions. This is limited to:

  • Character limited via ${field|#...}
  • Placeholder/optionality via ${field|?}

This is extremely limiting. There is no way to add to / transform the content a field used in a title expression without using kludgy workarounds.

Why is this a problem for you?

The core problem it limits the usefulness of title expressions. For example, while it is often useful to display a date in the title of nodes tagged with #todo and the like, these additions to the title become extremely long, especially when a start and end time are part of that date field. By allowing other types of date formatting options (as suggested https://ideas.tana.inc/posts/135-format-date-fields-in-build-in-title), we would gain a lot of flexibility in the way we build titles.

Another case comes from the potential addition of delimiters. Suppose I want to have all todos with a due date have the title structure in (1) and all todos without a due date have the title structure in (2):

(1) todo name | due date #todo
(2) todo name #todo

That is, when there is a due date, it is used in the title but is separated by a vertical line |. Currently. it is not possible to have condition separators without a unpleasant workaround.

Suggest a solution

The core syntax I would suggest is the following:

unformatted field = ${field name}
formatted field = ${field name|<formatting options>}

That is, use the current formatting syntax for title expressions, just expand the options. It would be great to eventually get something like Python f-strings .

⁨2⁩ ⁨Comments⁩

A ternary operator that evaluates based on a field value would be useful. E.g. If I had a boolean "Is JSON" field, I could display the node as a JSON object when it is true/checked. This would be useful for formatting a node and using it in the payload of the "Make API request" command. E.g.

${Is JSON} ? { "name": "${name}", "state": "${State}" } : ${name}

Date formating for title expresións to show exclusively time.
Example for a work cycle I use title expresions ${Start Date} - ${End Date} which results in the following:
Today, Wed, 28 Jun, 11:45 - Today, Wed, 28 Jun, 12:15
Desired output:
11:45-12:15
Suggest a solution:
unformatted field = ${Date Field}
formatted field = ${Date field|<mm:ss>}