Skip to content

Improve File Output Interpolation #599

Description

@Nerixyz

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions