Interpolation is currently done in https://github.com/Nerixyz/current-song2/blob/master/src/utilities/format_string.rs and implemented in https://github.com/Nerixyz/current-song2/blob/master/src/workers/file_output.rs.
One major issue with it is that some parts of the pattern might be empty and, in turn, some others should be hidden. Take the following example:
{artist} - {title} - {album-name?}
If album-name is empty, we don't want to include the trailing dash. For example, artist: MyArtist, title: MyTitle would interpolate to MyArtist - MyTitle - .
One approach to express this is to make parts fallible and to add blocks that "stop the propagation of failure". We could transform the above example to
{artist} - {title}{? - {album-name?}}
where {?<content>} will try to render <content> but fall back to an empty string if anything fails within. So if we had artist: MyArtist, title: MyTitle, album: MyAlbum we'd get MyArtist - MyTitle - MyAlbum but if we had artist: MyArtist, title: MyTitle, we'd get MyArtist - MyTitle.
I think we could also get rid of the question mark in album-name. It's a bit confusing to have it there.
Interpolation is currently done in https://github.com/Nerixyz/current-song2/blob/master/src/utilities/format_string.rs and implemented in https://github.com/Nerixyz/current-song2/blob/master/src/workers/file_output.rs.
One major issue with it is that some parts of the pattern might be empty and, in turn, some others should be hidden. Take the following example:
If
album-nameis empty, we don't want to include the trailing dash. For example,artist: MyArtist, title: MyTitlewould interpolate toMyArtist - MyTitle -.One approach to express this is to make parts fallible and to add blocks that "stop the propagation of failure". We could transform the above example to
where
{?<content>}will try to render<content>but fall back to an empty string if anything fails within. So if we hadartist: MyArtist, title: MyTitle, album: MyAlbumwe'd getMyArtist - MyTitle - MyAlbumbut if we hadartist: MyArtist, title: MyTitle, we'd getMyArtist - MyTitle.I think we could also get rid of the question mark in
album-name. It's a bit confusing to have it there.