Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the optional argument fallback_policy to the map_text filter #210

Open
lquerel opened this issue Jun 12, 2024 · 0 comments
Open

Add the optional argument fallback_policy to the map_text filter #210

lquerel opened this issue Jun 12, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@lquerel
Copy link
Contributor

lquerel commented Jun 12, 2024

This PR describes the addition of a new optional argument to the map_text filter to define the behavior of this filter when an entry doesn’t exist in the weaver.yaml config file.

The map_text filter already supports the following arguments: map_text("<text_map_id>" [, "<default_value>"]).

This issue adds the concept of a fallback policy, defining more precisely the behavior of this filter when the input doesn't match any entries in the text_maps configuration.

The new optional parameter fallback_policy will accept one of the three possible configurations:

  • input: When this behavior is set, and there is no entry matching the input, the input is returned by the filter. This was the behavior of the filter when no default value was provided.
  • default: When this behavior is set, and there is no entry matching the input, the default value is returned by the filter. This was the behavior of the filter when a default value was provided. Using fallback_policy=default and not providing a default_value is considered an error, and the filter will emit an error.
  • error: When this behavior is set, and there is no entry matching the input, the filter will emit an error. This specific configuration was not supported in the previous version of the map_text filter.

By making the fallback policy explicit, it is now possible, for example, to specify that we want to fail the doc/code generation if the text_map configuration is incomplete.

@lquerel lquerel added the enhancement New feature or request label Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: No status
Development

No branches or pull requests

1 participant